Ways of parsing xml document, DOT NET Programming

What are the ways of parsing XML document?

The XML parser sits in between the XML document and the application who want to use the XML document. The Parser exposes a set of well defined interfaces which can be used by the application for adding, deleting, and   modifying the XML document contents. Now whatever interfaces XML parser exposes must be standard or else that would lead to different Vendors preparing their own custom way of interacting with the XML document.

There are 2 standard specifications which are very common and should be followed by a XML parser:-

DOM: - Document Object Model.

The DOM is a W3C recommended way for treating XML documents. In DOM we load the whole XML document into memory and allow us to manipulate the structure and data of XML document.

SAX: - Simple API for XML.

The SAX is an event driven way for processing XML documents. In the DOM we load the entire XML document into memory and then application manipulates the XML document. But this is not always the best way to process large XML documents which have huge data elements. For illustrate  you only want one element from the entire XML document or you only want to see if the XML is proper that  means loading the whole XML in memory will be quiet resource intensive. The SAX parsers parse the XML document sequentially and emit events such as start and end of the document, elements, text content etc. Therefore the applications who are interested in processing these events can register implementations of callback interfaces. The SAX parser then only sends those event messages which the application has demanded.


Figure: - DOM Parser loading XML document

The above is a pictorial representation of how a DOM parser works. The application queries the DOM Parser for the "quantity" field. The DOM parser loads the complete XML file into the memory.


Figure: - Returning the Quantity value back to application

The DOM parser then picks up the "quantity" tag from the memory loaded XML file and then returns back to the application.


Figure: - SAX parser in action

The SAX parser does not load the entire DOM into memory but has event based approach. The SAX parser while parsing the XML file emits events. For e.g. in the above figure it has emitted Invoice tag start event, Quantity tag event , Amount Tag event, and Invoice end tag event. But our application software is only interested in the quantity value. Hence the application has to register to the SAX parser saying that he is only interested in the quantity field and not any other field or element of the XML document. Depending on what interest the application software has SAX parser only sends those events to the application, the rest of events is suppressed. For illustrate in the above figure only quantity tag event is sent to the application software and the rest of the events are suppressed.

Posted Date: 9/25/2012 2:49:15 AM | Location : United States

Related Discussions:- Ways of parsing xml document, Assignment Help, Ask Question on Ways of parsing xml document, Get Answer, Expert's Help, Ways of parsing xml document Discussions

Write discussion on Ways of parsing xml document
Your posts are moderated
Related Questions
What is Windows DNA architecture? The Windows Distributed internet Applications Architecture (DNA) is a Microsoft blueprint for scalable, robust, & distributed business softwar

What are LeaseTime, Sponsorship Time, Renew on Call Time and Lease Manager Poll Time? In the normal .NET environment objects lifetime is managed by garbage collector. But inrem

What does Xml Validating Reader class do? The XmlTextReader class does not validate the contents of an XML source against a schema. The correctness of the XML documents can be

What is a fish bone diagram? Dr. Kaoru Ishikawa discovered the fishbone diagram. Therefore, it can be also known as Ishikawa diagram. The Fishbone diagram is an analysis dia

31: Need to develop Doctor Appointments application in .NET Project Description: I am seeking a .NET Web application which can do the subsequent: 1. Taking doctors and

Project Description: We want to design and develop a new Sportbook Platform from scratch, subsequent functionality: - Have a full functionality like other similar websites (S

Give a brief introduction to Binders. Binders are used by DLR to communicate with not the .NET Framework but also with a variety of other services, like Silverlight and COM. Th

Question: (a) List and describe the four parameters contained in the second section of the AdRotator Scheduler File. (b) Distinguish between the following types of "Locks"

What is AppSetting Section in "Web.Config" file? Web.config file describe the configuration for a webproject. By Using "AppSetting" section we can define user defined values. T

What is a Web Service? The Web Services are the business logic components which provide the functionality via the Internet using standard protocols like HTTP. The Web Servic