A program that interprets the contents of an XML file and determines what to do with its input.
A D V E R T I S E M E N T
An XML parser is a software that reads XML files and makes the information from those files available to applications and programming languages, usually through a known interface like the DOM. The XML parser is responsible for testing whether a document is well-formed and it will also check for validity (ie, it determines if the document follows the rules of the DTD or XML schema). ...
Microsoft's XML Parser
Microsoft's XML parser is a COM component that comes with
Internet Explorer 5 and higher. After installing Internet
Explorer, the parser is available to scripts.
Microsoft's XML parser supports all the necessary functions
of the node tree.To traverse access the nodes and their attribute
values, insert and delete nodes, and convert the node tree back
to XML.
The most commonly used node types
supported by Microsoft's XML parser is described below:
Type of Node
Example
Processing instruction
<?xml version="1.0"?>
Element
<drink type="beer">Carlsberg</drink>
Attribute
type="beer"
Text
Carlsberg
MSXML Parser 2.5 is the XML parser that is included with
Windows 2000 and IE 5.5.
MSXML Parser 3.0 is the XML parser that is included with IE
6.0 and Windows XP.
Features MSXML 3.0 parser:
JavaScript, VBScript, Perl, VB, Java, C++, etc. support
Complete XML support
Full DOM and Namespace support
DTD and validation
Complete XSLT and XPath support
SAX2 support
Server-safe HTTP
To create an instance of Microsoft's XML parser with
JavaScript, use the following code:
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
Use the following code, to create an instance of Microsoft's XML parser with VBScript.
set xmlDoc=CreateObject("Microsoft.XMLDOM")
Use the following code,to create an instance of Microsoft's XML parser in an ASP page (using VBScript), use the following code:
set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
Code written below loads an existing XML document ("employee.xml") into Microsoft's XML parser:
The first line of the script above creates an instance of the Microsoft XML parser. The third line tells the parser to load an XML document called "employee.xml". The second line turns off asynchronized loading, to make sure that the parser will not continue execution of the script before the document is fully loaded.
XML Parser in Mozilla Browsers
In Mozilla Plain XML documents are displayed in a tree-like structure (just like IE).
Mozilla browsers also supports parsing of XML data by using JavaScript. The parsed data can be presented by HTML.
Use the following code, for creating an instance of the XML parser with JavaScript in Mozilla browsers.
var xmlDoc=document.implementation.createDocument("ns","root",null)
The first parameter, ns, defines the namespace used
for the XML document. The second parameter is the
XML root element in the XML file. The third parameter, null, is
always null because it is not implemented yet.
The code below loads an existing XML document
("employee.xml") into Mozillas' XML parser:
<script type="text/javascript">
var xmlDoc=document.implementation.createDocument("","",null);
xmlDoc.load("employee.xml");
...
...
</script>
The first line of the script above creates an instance of the XML parser. The second line tells the parser to load an XML document called "employee.xml".
The next line describes the root element of the document (like it was saying: "this
document is a employee details"):
To Load an XML File - A Cross browser Example
The example given below is a cross browser example that loads an existing XML document ("employee.xml") into the XML parser:
<html>
<head>
<script type="text/javascript">
function loadXML()
{
//load xml file
// code for IE
if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("employee.xml");
getmessage()
}
// code for Mozilla, etc.
else if (document.implementation &&
document.implementation.createDocument)
{
xmlDoc= document.implementation.createDocument("","",null);
xmlDoc.load("employee.xml");
xmlDoc.onload=getmessage
}
else
{
alert('Your browser cannot handle this script');
}
function getmessage()
{
document.getElementById("to").innerHTML=
xmlDoc.getElementsByTagName("to")[0].firstChild.nodeValue
document.getElementById("from").innerHTML=
xmlDoc.getElementsByTagName("from")[0].firstChild.nodeValue
document.getElementById("message").innerHTML=
xmlDoc.getElementsByTagName("body")[0].firstChild.nodeValue
}
</script>
</head>
<body onload="loadXML()" bgcolor="yellow">
<h1>VYOMS Details</h1>
<p><b>To:</b> <span id="to"></span><br />
<b>From:</b> <span id="from"></span>
<hr />
<b>Message:</b> <span id="message"></span>
</p>
</body>
</html>
Loading XML Text Into the Parser
Internet Explorer supports two ways of loading XML into a
document object: the load() method and the loadXML() method. The
load() method loads an XML file and the loadXML() method loads a
text string that contains XML code.
The following code loads a text string into Microsoft's XML
parser:
<script type="text/javascript">
var txt="<company>"
txt=txt+"<to>VYOM</to><from>TCS</from>"
txt=txt+"<heading>Reminder</heading>"
txt=txt+"<body>Employee Details</body>"
txt=txt+"</company>"
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.loadXML(txt)
...
...
...
</script>
Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
Keywords: microsoft xml parser, c xml parser, free xml parser, xml document, sax xml parser
expat xml parser,
dom xml parser,
microsoft xml parser,
apache xml parser,
xml parser tutorial,
xml file parser,
simple xml parser,
xml parser example,
xsl parser,
xml parser 4.0,
xml parser examples,
msxml parser,
c# xml parser,
xslt parser,
python xml parser,
dtd parser,
asp xml parser,
xsd parser,
xml parser sample,
validating xml parser,
xml parser library,
xml parser api,
xml parser 4,
xml parser 3.0,
using xml parser,
xml parser pm,
msxml 4.0 parser,
oracle xml parser,