Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quickest/best way to read XML

Tags:

c#

xml

I need to read potentially large (~300mb) XML files, and edit some of the nodes. Basically I need to:

  • Read the XML from the start
  • Whenever I find a node called trgt
  • Add some text to it

What's the best way to approach this in C#? Which XML classes should I use to find and edit the nodes I need to change?

TIA

like image 603
Jimmy Collins Avatar asked Mar 15 '11 20:03

Jimmy Collins


People also ask

How can I read XML faster?

XmlReader is one of the fastest ways of reading in an XML file. It is forward-only, and read-only. The derived XmlTextReader is generally the class you would reach for. Bear in mind that the speed improvement is only appreciable for very, very large XML files.

What is the best program to open XML files?

XML files can be opened in a browser like IE or Chrome, with any text editor like Notepad or MS-Word. Even Excel can be used to open XML files.

Which person provide the fastest response while reading XML?

4 Answers. Show activity on this post. The fastest parser will be SAX -- it doesn't have to create a dom, and it can be done with partial xml, or progressively. Info on the PHP SAX parser (Expat) can be found here.

Is XML easy to parse?

Well parsing XML is not an easy task. Its basic structure is a tree with any node in tree capable of holding a container which consists of an array of more trees.


1 Answers

VTD-XML is the only XML parsing lib that supports a feature called incremental update. It is also memory efficient and performant. But it requires you to download it as a third party lib.

like image 104
vtd-xml-author Avatar answered Sep 29 '22 06:09

vtd-xml-author