Academic Tutorials



English | French | Portugese | German | Italian
Google

Home Source Codes E-Books Downloads Contact Us About Us

XML Tutorial
XML Introduction
XML How to use
XML Syntax
XML Elements
XML Attributes
XML Validation
XML Validator
XML Browsers
XML Viewing
XML CSS
XML XSL
XML Data Island
XML Parser
XML in Real Life
XML Namespaces
XML CDATA
XML Encoding
XML Server
XML Application
XML HTTP Request
XML Save Data
XML Behaviors
XML Technologies
XML Editors
XML Summary
XML as Data Source

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
AJAX Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PHP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
.NET (dotnet)
Microsoft.Net
XML Web Services
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills


XML Parser
Previous Next

XML Parser

A program that interprets the contents of an XML file and determines what to do with its input.

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:


<script type="text/javascript">
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("employee.xml")
... ... ...
</script>

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.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • connotea
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Netvouz
  • RawSugar
  • Reddit
  • scuttle
  • Shadows
  • Simpy
  • Smarking
  • Spurl
  • TailRank
  • Wists
  • YahooMyWeb

Previous Next

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,


HTML Quizes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
XML Quizes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizes
JavaScript Quiz
VBScript Quiz
AJAX Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizes
ASP Quiz
PHP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
.NET (dotnet) Quizes
Microsoft.Net Quiz
XML Web Services Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
Multimedia Quizes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Web Building  Quizes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Java Quizes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Programming Langauges Quizes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Soft Skills Quizes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz

Privacy Policy
Copyright © 2003-2008 Vyom Technosoft Pvt. Ltd., All Rights Reserved.