There are 3 preferable ways to read XML document.
- XMLDocument Class - It allows to insert, update, delete or move a node.
- XMLTextReader Class - It allows read data in fast forward-only manner.
- XMLValidatingReader Class - It allows to validate XML document against Document Type Definition (DTD), XML Schema definition(XSD) and XML Data Reduced(XDR).
XMLTextReader and XMLValidatingReader Class is derived from XMLReader class which provides
- read-only, and
- forward-only access to XML data.
Choosing between XMLDocument, XMLTextReader and XMLValidatingReader Class.
- Use XMLDocument when
- You want to perform operation like Insert, Update and delete.
- Memory is not a constraint
- Use XMLTextReader when
- You want to read data in forward-only manner.
- When memory is constraint.
- Use XMLValidatingReader when
- You want to validate XML document against DTD, XSD and XDR.