Francis

Francis

  • NA
  • 5
  • 0

Parsing XML and Organizing Appropriately

Jun 15 2010 10:57 AM

Hello
I am currently working with a large XML document with a bunch of data and elements, however I am only interested in a small part of the whole file.  I am attempting to parse the XML file w/ XPath or LINQ and store the values as a new XML document or in an array for later use. I have a question about what it can generally do.
I would like to take values that go under these tags (BusinessEntity, Name, Description; BusinessService, Name, Description)
Using LINQ and XPath, I've been able to get all the info in these tags, however I've only been able to simply store them in an array, there is no more information about it (i.e. Service 3 is under PO1, not PO2)
Is there anyway to make the information I gather have more history/info about it that makes it more descriptive?  Here is a VERY stripped down XML file I am working with, (the one I am parsing has a lot more other extraneous elements as well as duplicate names for entities/services that I'll deal with later...)
<Program>
<BusinessEntity>
<Name>PO1</Name>
<Description>DescribingPO1</Description>
  <BusinessServices>
  <BusinessService>
   <Name>Service1</Name>
   <Description>DescribingService1</Description>
  </BusinessService>
  <BusinessService>
   <Name>Service2</Name>
   <Description>DescribingService2</Description>
  </BusinessService>
  <BusinessService>
   <Name>Service3</Name>
   <Description>DescribingService3</Description>
  </BusinessService>
</BusinessServices>
</BusinessEntity>

<BusinessEntity>
<Name>PO2</Name>
<Description>DesribingPO2</Description>
<BusinessServices>
  <BusinessService>
  <Name>Service4</Name>
  <Description>Describing Service4</Description>
  </BusinessService>
</BusinessServices>
</BusinessEntity>
</Program>
 
I've heard some suggestions on serialization, but it seems that it still only simple stores the values, vs. making entities and what not....
thanks for any suggestions

Answers (1)