|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Controlling XML Structure with XMLSerializationsince sliced bread! Since then, I have designed several XML files that I read and write via XMLSerialzation. A common feature most of these have are repeating nodes. I have figured out how to setup repeating nodes but I don't like how the resulting XML looks. I have heard that it really shouldn't matter how an XML file looks as long as it contains the right data. But some of these may need to be occasionally manually edited, and I just think they don't look right. Example: Public Class Child Private _Prop1 as String Private _Prop2 as String Public Property Prop1 as String Get Return _Prop1 End Get Set(ByVal value as String) _Prop1 = value End Set End Property Public Property Prop2 as String Get Return _Prop2 End Get Set(ByVal value as String) _Prop2 = value End Set End Property End Class Public Class Parent Private _Children as List(of Child) Public Property Children as List(of Child) Get Return _Children End Get Set(ByVal value as List(of Child) _Children = value End Set End Propertyt End Class This produces an XML file that looks like (with two children): <Parent> <Children> <Child> <Prop1 /> <Prop2 /> </Child> <Child> <Prop1 /> <Prop2 /> </Child> </Children> </Parent> I would prefer that the XML file look like this: <Parent> <Child> <Prop1 /> <Prop2 /> </Child> <Child> <Prop1 /> <Prop2 /> </Child> </Parent> Any suggestions on how to structure the Classes to accomplish this? Hello za***@construction-imaging.com,
The .NET Serializer actually produces correct XML. Any repeating nodes *SHOULD* be contained within a node that depicts plurality. -Boo Show quoteHide quote > When I figured out XMLSerialization, I thought that was the best thing > since sliced bread! > > Since then, I have designed several XML files that I read and write > via > XMLSerialzation. A common feature most of these have are repeating > nodes. I have figured out how to setup repeating nodes but I don't > like how the resulting XML looks. I have heard that it really > shouldn't matter how an XML file looks as long as it contains the > right data. But some of these may need to be occasionally manually > edited, and I just think they don't look right. > Example: > > Public Class Child > Private _Prop1 as String > Private _Prop2 as String > Public Property Prop1 as String > Get > Return _Prop1 > End Get > Set(ByVal value as String) > _Prop1 = value > End Set > End Property > Public Property Prop2 as String > Get > Return _Prop2 > End Get > Set(ByVal value as String) > _Prop2 = value > End Set > End Property > End Class > > Public Class Parent > Private _Children as List(of Child) > Public Property Children as List(of Child) > Get > Return _Children > End Get > Set(ByVal value as List(of Child) > _Children = value > End Set > End Propertyt > End Class > > This produces an XML file that looks like (with two children): > > <Parent> > <Children> > <Child> > <Prop1 /> > <Prop2 /> > </Child> > <Child> > <Prop1 /> > <Prop2 /> > </Child> > </Children> > </Parent> > I would prefer that the XML file look like this: > > <Parent> > <Child> > <Prop1 /> > <Prop2 /> > </Child> > <Child> > <Prop1 /> > <Prop2 /> > </Child> > </Parent> > Any suggestions on how to structure the Classes to accomplish this? >
MDI Min Max - still there
Q: closing forms CURRENT INDEX of Iteration on ILIST collection ? da.update bool--> yes/no 1.1 equivalent for Drawing.Icon.ExtractAssociatedIcon? Accessing the Class Name of a Shared Method Writing Custom DLLs in VB.net 2 Re: Reading a list of users from XP VS 2005: Forms Designer Clears CancelButton and AcceptButton on Compile use try catch to check a text box |
|||||||||||||||||||||||