![Page 1: 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](https://reader036.vdocuments.net/reader036/viewer/2022082518/5697bfd21a28abf838cabd95/html5/thumbnails/1.jpg)
XML Parser using JavaScript
![Page 2: 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](https://reader036.vdocuments.net/reader036/viewer/2022082518/5697bfd21a28abf838cabd95/html5/thumbnails/2.jpg)
2Microsoft
• 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
![Page 3: 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](https://reader036.vdocuments.net/reader036/viewer/2022082518/5697bfd21a28abf838cabd95/html5/thumbnails/3.jpg)
3Microsoft
• 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:
<script type="text/javascript">
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
</script>• 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
![Page 4: 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](https://reader036.vdocuments.net/reader036/viewer/2022082518/5697bfd21a28abf838cabd95/html5/thumbnails/4.jpg)
4Microsoft
• Synchronous load the XML Data
<script type="text/javascript">
xmlDoc.async="false";
</script>• 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
![Page 5: 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](https://reader036.vdocuments.net/reader036/viewer/2022082518/5697bfd21a28abf838cabd95/html5/thumbnails/5.jpg)
5Microsoft
Callback function
<script type="text/javascript">
xmlDoc.onreadystatechange = function name
</script>• Calls the callback function on change of every state while
loading the xml document.
XML Parser in Microsoft Browser
![Page 6: 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](https://reader036.vdocuments.net/reader036/viewer/2022082518/5697bfd21a28abf838cabd95/html5/thumbnails/6.jpg)
6Microsoft
XML Parser in Microsoft Browser
Ready States in Microsoft Browsers
1 Loading Preparing to read the XML file. Did not try yet
2 Loaded Parsing the XML file. Object model still not available
3 Interactive Part of XML file successfully parsed and read in. Object model partially available for read only
4 Completed Loading of the XML file has been completed, successfully or unsuccessfully
![Page 7: 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](https://reader036.vdocuments.net/reader036/viewer/2022082518/5697bfd21a28abf838cabd95/html5/thumbnails/7.jpg)
7Microsoft
• Load XML Document
<script type="text/javascript">
xmlDoc.load("abc.xml");
</script>
• Tells the parser to load abc.xml file.
XML Parser in Microsoft Browser