Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing an XML file in C# [duplicate]

Tags:

c#

xml

What is the fastest method of parsing an XML file in C#? I'm using .Net 2.0

like image 523
Steven Williams Avatar asked Sep 03 '08 16:09

Steven Williams


People also ask

What is XML parser in C?

The Oracle XML parser for C reads an XML document and uses DOM or SAX APIs to provide programmatic access to its content and structure. You can use the parser in validating or nonvalidating mode. This chapter assumes that you are familiar with the following technologies: Document Object Model (DOM).

What is XML formatting?

What is XML? The Extensible Markup Language (XML) is a simple text-based format for representing structured information: documents, data, configuration, books, transactions, invoices, and much more. It was derived from an older standard format called SGML (ISO 8879), in order to be more suitable for Web use.

What is an XML data file?

To summarize: An XML file is a file used to store data in the form of hierarchical elements. Data stored in XML files can be read by computer programs with the help of custom tags, which indicate the type of element.


2 Answers

If you're using .Net 2 then the XmlReader and XmlDocument are about it.

If you can use .Net 3.5 then the new Linq to Xml methods are a big improvement.

like image 195
Keith Avatar answered Oct 23 '22 03:10

Keith


I haven't benched-marked it myself, but when I've asked about it in the past I've been told that XmlDocument is supposed to be faster. I have my doubts, though, since XmlDocument would need to create a DOM while XmlReader does not.

like image 24
Joel Coehoorn Avatar answered Oct 23 '22 03:10

Joel Coehoorn