I am working on an order entry program and have a question related to
deserializing nodes with nested elements.
The purchase order contains multiple line items which I select using an
XmlNodeList. I am trying to deserialize the nodes using a foreach as follows:
foreach(XmlNode lineItem in LineItemsNodeList)
An abbreviated example of the nested lineItem node looks like this:
<LineItem>
<OrderLine>
<LineSequenceNumber>1</LineSequenceNumber1>
<PartQualifier1>BP</PartQualifier1>
<PartNumber1>BTI318</PartNumber1>
<OrderQuantity>6</OrderQuantity>
<UnitPrice>12.50</UnitPrice>
</OrderLiine>
<Reference>
<Description>HAPPY BIRTHDAY JOHN</Description>
</Reference>
</LineItem>
I have created an object to represent the Xml node with
[XmlRoot("LineItem")] and [XmlElement("ElementName")] for each of the other
elements.
I read the element into an XmlReader, create a serializer object, and then
deserialize the node.
My question is, should I deserialize the entire nested node, or should I
create two seperate objects to deserialize: One for the <OrderLinesection,
and one for the <Referencesection?
When trying to deserialize the entire nested node, the value of
<LineSequenceNumbergets assigned to <OrderLine>. What am I doing wrong?
What is the correct way to deal with this?
--
Jeremy
--
Jeremy