It’s been long time I manipulated raw XML. I have used XmlDocument and remember something called XDocument begining to evolve, but that was few years ago. What M$ recomends in these days?
Thanks in advance
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
XDocumentis part of LINQ to XML – and it’s definitely what I’d use for 99% of XML work these days.LINQ to XML isn’t quite what it sounds like – it’s not really a LINQ provider in the way that LINQ to SQL is, for example… it’s an XML API which has been designed to play well with LINQ to Objects. It supports a declarative construction model and its querying fits in very well with LINQ to Objects, allowing you to find elements, attributes etc really easily.
Oh, and its namespace support is awesomely simple:
Basically it’s lovely – it beats using XmlDocument and XmlReader into a cocked hat, for most situations. Occasionally
XmlReadermay be useful for streaming efficiency, but you can create anXElementfrom anXmlReader, which will just read the “current” element and leave theXmlReaderpositioned after it. This allows for sort of “structured streaming” with the benefits of LINQ to XML, so long as you only need one element (and any child elements, of course) at a time.With respect to eidylon’s answer: C# doesn’t support XML literals; it takes the view that a language shouldn’t get involved in a specific technology such as XML directly. How big a deal you believe that to be is a personal matter 🙂