Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML Parser using JavaScript. 2 Microsoft To manipulate an XML document in javascript, you need an XML parser. Today all browsers come with in-built parsers.

Similar presentations


Presentation on theme: "XML Parser using JavaScript. 2 Microsoft To manipulate an XML document in javascript, you need an XML parser. Today all browsers come with in-built parsers."— Presentation transcript:

1 XML Parser using JavaScript

2 2 Microsoft To manipulate an XML document in javascript, you need an XML parser. Today all browsers come with in-built parsers that can parse the XML document. The parser loads the document into your computer’s memory. Once the document is loaded, its data can be manipulated using the DOM(Document Object Model). There is significant differences in implementation of Microsoft Browser based XML parser and the Mozilla browsers based XML parser. XML Parser using JavaScript

3 3 Microsoft Microsoft’s XML parser is a COM component that comes with Internet Explorer 5 and higher. To load the XML Parser in JavaScript will have to follow series of steps. Create instance of XML Parser: var xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); This will load the xml parser in the memory and will wait for the xml document. This component will automatically get erased when you close the browser window or the Browser. Here the xmlDoc holds the XML Object for JavaScript. XML Parser in Microsoft Browser

4 4 Microsoft Synchronous load the XML Data xmlDoc.async="false"; This line turns off asynchronous loading, to make sure that the parser will not continue execution of the script before the document is fully loaded. XML Parser in Microsoft Browser

5 5 Microsoft Callback function xmlDoc.onreadystatechange = function name Calls the callback function on change of every state while loading the xml document. XML Parser in Microsoft Browser

6 6 Microsoft XML Parser in Microsoft Browser Ready States in Microsoft Browsers 1LoadingPreparing to read the XML file. Did not try yet 2LoadedParsing the XML file. Object model still not available 3InteractivePart of XML file successfully parsed and read in. Object model partially available for read only 4CompletedLoading of the XML file has been completed, successfully or unsuccessfully

7 7 Microsoft Load XML Document xmlDoc.load("abc.xml"); Tells the parser to load abc.xml file. XML Parser in Microsoft Browser


Download ppt "XML Parser using JavaScript. 2 Microsoft To manipulate an XML document in javascript, you need an XML parser. Today all browsers come with in-built parsers."

Similar presentations


Ads by Google