XML DOM introduction and example

xiaoxiao2021-03-06  43

Author: Anonymous Source: Network

1. Document Object Model (DOM) DOM is the programming foundation of HTML and XML documents, which defines the way to process the execution document. Programperspers can use DOM to add documents, locate document structures, and fill in the modified deletion of document elements. An important goal of W3C is to provide a programming interface that uses DOM to use in multiple platforms. W3C Dom is designed to suit multiple platforms that can be implemented using any programming language. 2. Node Interface XML Parser Use the DOM to retrieve and process when loading the XML document into the cache. The DOM uses a tree structure to represent an XML document. The document element is the highest level of the tree, which has one or more children's nodes to represent the branches of the tree. Node interface programs are often used to read and write individual elements in the XML node tree, and children's node properties of document elements can be used to construct individual elements nodes. XML Parser is used to prove that the DOM in the Web supports all functions of the node tree, and can access nodes and their properties, insert the delete node, and convert the nodes to XML. All Microsoft XML Parser functions get formal recommendation for W3C XML DOM, except for LOAD and LOADXML functions (formal DOM does not include standard Loading XML documents). There are 13 node types that are supported by Microsoft XML Parser. The commonly used nodes are listed below: Node type example document type processing instruction Element carlsberg attribute type = "beer" Text Carlsberg 3. Using XML Parser In order to process XML documents more skilled, you must use XML Parser. Microsoft XML Parser is a COM component with IIS5.0, once IIS5.0 is installed, Parser can utilize the HTML document and scripts in the ASP file.

Microsoft XMLDOM Parser supports the following programming mode: ---- Support JavaScript, VBScript, Perl, VB, Java, C , etc. - - Support W3C XML 1.0 and XML DOM ---- Support DTD and Validation if Ie5.0 In JavaScript, you can use the following XML document object: VAR XMLDoc = New ActiveXObject ("Microsoft.xmLDom") If you use VBScript, you can use the following XML document object: set Xmldoc = createObject ("Microsoft.xmLDom") If you use ASP You can use the following XML document object: SET XMLDOC = Server.createObject ("Microsoft.xmLDom") 4. Load an XML file to the XML document in which the following code is loaded in XML Parser: