Ways of parsing xml document, DOT NET Programming

Assignment Help:

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.

56_DOM.png

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.

1262_DOM1.png

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.

2241_DOM2.png

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.


Related Discussions:- Ways of parsing xml document

I need custom login page for sharepoint, I need Custom Login Page for Share...

I need Custom Login Page for Sharepoint 2013 with Active Directory Project Description: I would like to prepare a webpart or an application for Sharepoint 2013 foundation.

How is a property designated as read-only, How is a property designated as ...

How is a property designated as read-only?  In VB.NET: Public Read-Only Property Property Name  As Return Type Get ?Your Property execution goes in here End Get End Property.

Print floyd''s triangle - c# program, Print Floyd's Triangle - C# Program ...

Print Floyd's Triangle - C# Program I am unable to make out how to print Floyd's Triangle in C# language. Can anyone suggest me any example for this.

Use of hidden frames to cache client data, How can you use Hidden frames to...

How can you use Hidden frames to cache client data? This technique is implemented by developing a Hidden frame in page which will have your data to be cached. T cols="100

Develop a new website, I need to develop a new website. Previous site was n...

I need to develop a new website. Previous site was not good and I need better one with not only static but using also more details . Skills required: .NET, MySQL, C# Programm

What is common language specification, What is Common Language Specificatio...

What is Common Language Specification (CLS)? CLS is a set of essential rules, which must be followed by each .NET language to be a .NET- compliant language. It enables interope

I want licensing system, Project Description: I'm presently seeking at l...

Project Description: I'm presently seeking at least one more coder that will help me out manage all my concepts and in that way we will share each other's experience and make te

Modification in .net website, Modification in .net website I need some m...

Modification in .net website I need some modification in asp.net website. It's an e-commerce site. Skills required: .NET, HTML, eCommerce, Shopping Carts, Website Design

Develop a project using microsoft active directory, Net project Project ...

Net project Project Description: We want to make .net project Microsoft Active Directory, PMS Lync 2010 - 2013 databases creating a license key for their SW generati

Web application and xml data storage, Web application and XML data storage ...

Web application and XML data storage One person should create a library (Java package of classes) for managing the list of bibliography entries, and for saving and loading th

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd