Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complex Nested XML

Status
Not open for further replies.

dpdoug

Programmer
Nov 27, 2002
455
US
This is part of an XML file that I need to build programatically. I am building it with the XMLTextWriter object in .NET -- which is a great tool for what I'm doing. The problem is that the nesting in this is so complex and so deep, that it never nests them right and I can never seem to get all of the objects in the right order to get them to nest exactly correct.

Any suggestions?

Code:
<OrderDetail>
 <ListOfItemDetail>
  <ItemDetail>
   <PricingDetail>
    <ListOfPrice>
     <Price>
      <UnitPrice>
        <UnitPriceValue>450</UnitPriceValue>
	<UnitOfMeasurement>
	  <UOMCoded>EA</UOMCoded>
	</UnitOfMeasurement>
      </UnitPrice>
      <PriceBasisQuantity>
	<Quantity>
	  <QuantityValue>1</QuantityValue>
	</Quantity>
      </PriceBasisQuantity>
      <ValidityDates>
	<StartDate>2/25/2005</StartDate>
	<EndDate>3/27/2005</EndDate>
       </ValidityDates>
     </Price>
    </ListOfPrice>
    <TotalValue>
      <MonetaryValue>
        <MonetaryAmount>450</MonetaryAmount>
      </MonetaryValue>
    </TotalValue>
   </PricingDetail>
 <BaseItemDetail>
   <LineItemNum>
     <BuyerLineItemNum>12354</BuyerLineItemNum>
   </LineItemNum>
   <ItemIdentifiers>
    <PartNumbers>
     <SellerPartNumber>
       <PartNum>
         <PartID>100-1520</PartID>
       </PartNum>
     </SellerPartNumber>
    </PartNumbers>
    <ItemDescription>Backhoe</ItemDescription>
   </ItemIdentifiers>
</BaseItemDetail>
</ItemDetail>
</ListOfItemDetail>
</OrderDetail>

 
I would break it up into separate methods within your class, passing the XmlTextWriter object between them. That way you don't lose track of your open element/close element code.

So, one method for OrderDetail, and another for ListOfPrice, TotalValue, PricingDetail, BaseItemDetail, and ItemIdentifiers.

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top