What's best way to read XML ?
My xml is like that I'll have a lot of
<A> and <B>, not sure how many will be there and I have to read the whole xml file.
I can not say that the child element like
<180> will be there under <A> for sure. So does the other element.
But if it's there I have to read it.
Should I use LINQ or XPath or XMLReader ? Which one will be better and easier?
<A>
<180>20130218</180> ///180 is here
<170>5</170>
<220>20080210</220>
<730 CLID='AAA' KW='BBB' KW2='INTERNATIONAL'>
<731>BBB INTERNATIONAL AG</731>
<732>XXX</732>
<735>US66</735>
<734>YYY</734>
</730>
<300>
<301>
<320>20071100</320>
<310>12345</310>
</301>
<330>US</330>
</300>
</A>
<A> ///180 is not here
<170>5</170>
<220>20080210</220>
<730 CLID='AAA' KW='BBB' KW2='WORLD'>
<731>BBB INTERNATIONAL AG</731>
<734>YYY</734>
</730>
<300>
<301>
<320>20071100</320>
<310>12345</310>
</301>
<330>UK</330>
</300>
</A>
<B>
<180>20130218</180>
<170>5</170>
<220>20080210</220>
<730 CLID='AAA' KW='BBB' KW2='INTERNATIONAL'>
<731>BBB INTERNATIONAL AG</731>
<732>XXX</732>
<733>JP</733>
<735>JP66</735>
<734>YYY</734>
</730>
<300>
<301>
<320>20071100</320>
<310>12345</310>
</301>
<330>JP</330>
</300>
</B>
Should I use LINQ or XPath or XMLReader ? Which one will be better and easier?
XDocument (Linq-to-XML) will be the easiest. And it can probably do what you want but you should be clearer about the desired outcome.
XML can be as large as 150 KB.
No problem at all. Only start to consider XmlReader when you reach 150 MB.