Home  >  Article  >  Backend Development  >  Detailed analysis of Microsoft's xml parser

Detailed analysis of Microsoft's xml parser

黄舟
黄舟Original
2017-03-29 16:00:371831browse

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")

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")

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

set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")

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

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>

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>

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!

Statement:
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