0

I have following XML:

<?xml version="1.0" encoding="utf-8"?>
<start>
    <Current CurrentID="5">
        <GeoLocations>
            <GeoLocation id="1" x="78492.61" y="-80973.03" z="-4403.297"/>
            <GeoLocation id="2" x="78323.57" y="-81994.98" z="-4385.707"/>
            <GeoLocation id="3" x="78250.57" y="-81994.98" z="-4385.707"/>
        </GeoLocations>
        <Vendors>
            <Vendor id = "1" x="123456" y="456789" z="0234324"/>
        </Vendors>
        <Bankers>
            <Banker id = "1" x="23432" y="3243243" z="5154445"/>
        </Bankers>
        <Hospitals>
            <Hospital id = "1" x="324324" y="23432" z="23432432"/>
        </Hospitals>
    </Current>
</start>

I need a parser XML to LINQ to load data to LIST.

If i have multiple sub-sections in one XML like i have in my example with Vendors and banks, hospitals do i need a seperate list for each of them and how do i link those list together when pulling CurrentId= 5?

Pratik
  • 2,532
  • 2
  • 21
  • 29
Tagyoureit
  • 359
  • 1
  • 5
  • 18

1 Answers1

1

Make a base class which will have id,x,y,z, and have Vendors,Bankers and Hospitals extend it.

Then you can have a collection of the base class, and add to it the classes that inherit from it.

Noctis
  • 11,507
  • 3
  • 43
  • 82