Home > Backend Development > XML/RSS Tutorial > Detailed analysis of Microsoft's xml parser

Detailed analysis of Microsoft's xml parser

黄舟
Release: 2017-03-29 16:00:37
Original
1883 people have browsed it

Use XML parser
Microsoft's XML parser is bundled with IE5.0+ browser.

Once you install IE5.0, you get an XML parser. In addition to being called internally by the browser, this browser can also be called in scripts or programs. This parser is characterized by supporting a programming language-independent programming model. It supports the following technologies:

JavaScript, VBScript, Perl, VB, Java, C++, etc.
W3C XML 1.0 and XML DOM
DTD and XML document verification
If the browser uses JavaScript as the scripting language, then use the following code to create the XML document object:

var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
Copy after login

If the browser uses VBScript as the scripting language, then use the following The code can create an XML document object:

set xmlDoc=CreateObject("Microsoft.XMLDOM")
Copy after login

If you use VBScript scripting language in an ASP program, you can use the following code form:

set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
Copy after login

---- -------------------------------------------------- --------------------------

Load the XML document into the parser
Use script code to The XML document is loaded into the parser.

The following code loads an XML document into the parser:

<script type="text/javascript">
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("note.xml")
// ....... processing the document goes here
</script>
Copy after login

The second line of code creates an instance of the Microsoft XML parser.

The third line of code turns off asynchronous loading to ensure that the XML parser will not parse the XML document before it is completely loaded.

The fourth line tells the parser that the name of the XML document that needs to be loaded is note.xml.

-------------------------------------------------- ------------------------------------

Load pure XML documents by characters Parser
The parser can load XML text from a text string.

The following code demonstrates loading a text string into the parser:

<script type="text/javascript">
var text="<note>"
text=text+"<to>Tove</to><from>Jani</from>"
text=text+"<heading>Reminder</heading>"
text=text+"<body>Don&#39;t forget me this weekend!</body>"
text=text+"</note>"
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.loadXML(text)
// ....... processing the document goes here
</script>
Copy after login

Note that the "loadXML()" method is used to load the string here (instead of the one used previously) "load()" method), "loadXML()" is used to load strings, and "load()" is used to load XML documents.

The above is the detailed content of Detailed analysis of Microsoft's xml parser. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template