none
DataTables in Visual C++ .NET RRS feed

  • Question

  • What is the difference between XmlReader, XmlTextReader and LoadXml ? How to decide which is used for reading XML file?
    Monday, September 26, 2016 5:59 AM

Answers

  • They are very similar.

    XmlReader

    "Represents a reader that provides fast, non-cached, forward-only access to XML data."

    XmlTextReader

    "Represents a reader that provides fast, non-cached, forward-only access to XML data.

    Starting with the .NET Framework 2.0, we recommend that you use the System.Xml.XmlReader class instead."

    XmlTextReader inherits from XmlReader and has some extra methods like "ResetState".

    Do not use XmlTextReader, use XmlReader instead.

    LoadXml is a method that is part of the XmlDocument which represents an XML document.

    And the different between XmlDocument and XmlReader are that:

    XmlDocument loads entire document into memory and allows you to modify & query the content. Then you can save the modified XML document back to file.

    XmlReader provides a read only & forward only access to the content of XML document - one element at the time.

    And here is a good post that to help you decide when to use XmlReader vs. XmlDocument.

    Deciding on when to use XmlDocument vs XmlReader

    Monday, September 26, 2016 8:06 PM