xml| objects
XML Document Object Model
1 DOMDocument object: This object describes all the document mapping tables, and the document mapping table contains all the information in the XML document.
Common methods
Common Properties
2 IXMLDOMNode Object: This object describes the nodes in the XML document. This node can be an element, attribute, processing instruction, text, or other information stored in an XML document.
Common methods
Common Properties
3 IXMLDOMNodeList Object: This object describes the collection of IXMLDOMNode objects and can use that object to traverse the collection. The set of nodes in the IXMLDOMNodeList object can be asked numerically.
Common methods
Common Properties
4 Ixmldomparseerror Object: This object is used to validate the correctness of XML documents for schemas or DTDs, and to obtain error messages generated during validation.
Common methods
Common Properties
* Common Methods for DOMDocument objects:
A) createelement (elementname)----This method creates an element node named with this parameter, with the element name as the parameter. (You cannot create a namespace-restricted element.) If you want to create a restricted element of a namespace, you must use the CreateNode () method)
Example: Doc.createelement ("PRODUCT")
b) CreateAttribute (AttributeName)----This method creates an attribute node named with this parameter, with the property name as the parameter.
Example: Doc.createattribute ("PRODID")
c) createcomment (text)----The method creates a comment node that contains this string as a string parameter.
Example: Doc.createcomment ("This are an XML document")
D createTextNode (Text)----The method creates a body node that contains the specified string as a string parameter.
Example: Doc.createtextnode ("Sony Workman")
e) CreateNode (Type,name,namespace-uri)----This method to create an element node. Three parameters, the type argument is variant, can be either a string or an integral type. The second argument is a string that represents the name of the node that will be created. The third parameter is a string representing the Namespace-uri. If Namespace-uri is an empty string, the newly created node does not have a namespace URI
Example: Doc.createnode ("element", "PRODUCT", "")
Doc.createnode ("element", "prod:product", "blog.csdn.net/fcrpg2005")
Doc.createnode (1, "PRODUCT", "")
f) getElementsByTagName (elementname)----The method takes a string as a parameter. This string is the element to search for. Returns a IXMLDOMNodeList object that contains a collection of nodes that specify the name of the element. These node letters can be used to navigate through the manipulation of values stored in the specified element.
Example: Doc.geteelmentsbytagname ("Price")
g) Load (XmlDocument)----The method takes a string as a parameter. This string is the address of the XML document (HTTP address or local address)
Example: Doc.load ("Http://blog.csdn.net/fcrpg2005/product.xml")
Doc.load ("D:\product.xml")
h) Loadxml (String)----This method loads the formed XML code or the entire XML document into the DOMDocument object.
Example: Doc.loadxml ("<?xml Version=1.0><products><product><name>barbie Doll</name></ Product></products> ")
i) transformnode (Stylesheet Object)----The method takes a style table object as a parameter. Process the node by adding the corresponding style table to the XML document, and then return the result of the transformation.
Example: Doc.transformnode ("product.xsl")
j) AppendChild (child node)----The method takes an object as an argument. Add this object as the last child node on the XML document. CreateNode () or createelement () methods can create nodes or elements. However, they do not add new nodes to the document tree structure. Instead, you need to use the AppendChild () method, the InsertBefore () method, or the ReplaceChild () method to add the newly created node.
Example: Doc.appendchild (root)----Ps:root is a node created with the CreateNode () or createelement () method
k) Save (destination)----The method takes an object as an argument. This object can be a DOMDocument object or it can be a filename. The Save () method saves the DOMDocument object to the specified destination.
Example: Doc.save ("Http://blog.csdn.net/fcrpg2005/product.xml")
* DOMDocument Objects Common Properties:
A) Async----This property to specify whether to allow asynchronous loading. Property Async to take a Boolean value.
Example: Doc.async = false--sync
b childnodes----This property returns the collection of child nodes belonging to a parent node (that is, an array object that returns all child elements of the current element). The value of this property is the type of the object ixmldomnodelist.
Example: var Firstelem = Doc.childNodes.item (1)
c) DocumentElement----This property contains the root element of the XML document represented by the object DOMDocument.
Example: var root = doc.documentelement
D) FirstChild----This property to return the first child node of the parent element. The element is read-only.
Example: var Firstelem = Doc.firstchild
e) LastChild----This property to return the last child node of the parent element.
Example: var Lastelem = Doc.lastchild
f) ParseError----This property returns an object that contains most of the most recently generated error messages.
Example: var error = Doc.parseerror
g) ReadyState----This property returns the state of the XML document. It shows whether the document is fully loaded. 4 states: 0-Uninitialized, 1-loading, 2-loaded, 3-interactive, 4-completed
Example: var stateinfo = doc.readstate
if (Stateinfo = = 4) {//Document loading
Coding
}
h) XML----This property returns a node with an XML representation of its child nodes.
Example: document.write (Doc.xml)
i) Validateonparse----This property to specify whether the parser validates its legality when parsing an XML document.
Example: Doc.validateonparse = True
* * IXMLDOMNode objects commonly used methods:
A) appendchild (newchild)----The method adds the node newchild to the end of the child node of the node used by the method.
b insertbefore (NewNode, Refnode)----This method inserts a new node NewNode into an existing node refnode.
c) removechild (nodename)----This method deletes the specified node.
d) replacechild (NewNode, OldNode)----This method replaces the old node OldNode with the new node NewNode.
e) haschildnodes ()----If the IXMLDOMNode object has child nodes, the method returns a true (true) value.
f) CloneNode (Boolean)----If the argument Boolean is True, the method returns a full clone of the IXMLDOMNode object. The Clone node contains the same child nodes as the original node.
* * IXMLDOMNode Objects Common Properties:
A) nodename----return the node name.
b) NodeType----return the node type.
c) NodeValue----Returns the text contained by the node.
d) childnodes----Returns the set of child nodes of the node represented by the IXMLDOMNode object.
e) FirstChild----Returns the first child node of the node.
f) LastChild----Returns the last child node of the node.
g) Text----Returns the text of the IXMLDOMNode in the IXMLDOMNode object.
h) XML----Returns the XML code of the IXMLDOMNode object
Common methods for IXMLDOMNodeList objects:
A) item (number)----This method returns the node for the specified numeric value.
b) NextNode ()----The method returns the next node in the Node-set.
IXMLDOMNodeList Objects Common Properties:
Length----Get the number of nodes in the node set.
Ixmldomparseerror Objects Common Properties:
A) ErrorCode----This property contains an error code with a type of long integer. This property returns 0 if there are no errors in the XML document.
b) Reason----This property contains a string that explains the cause of the error.
Line----This property stores a long integer that represents the number of error rows.
D) Linepos----This property stores a long integer that represents the error row position.
e) Srctext----This property contains the line of string that caused the error.