Set of common phpxml functions (more detailed ). 1. Functions of DOM a and DOMDocument-load (): loads xml files. usage: DOMDocument-load (stringfilename) parameter: filename, xml file; return: TRUE if successful, error
1. DOM functions
A. DOMDocument-> load ()
Purpose: load xml files.
Usage: DOMDocument-> load (string filename)
Parameter: filename, xml file;
Return: if the operation succeeds, TRUE is returned. if the operation fails, FALSE is returned.
B. DOMDocument-> loadXML ()
Purpose: load xml code
Usage: DOMDocument-> loadXML (string source)
Parameter: source xml code;
Return: if the operation succeeds, TRUE is returned. if the operation fails, FALSE is returned.
C. DOMDocument-> getElementsByTagName_r ()
Purpose: search by tag name
Usage: DOMDocument-> getElementsByTagName_r (string name)
Parameter: name, label name;
Return value: the new DOMNodeList object.
D. DOMDocument-> getElementById ()
Purpose: search by tag name
Usage: DOMDocument-> getElementById (string elementId)
Parameter: elementId, tag id;
Return value: the new DOMNodeList object.
E. DOMDocument-> createElement_x_x ()
Purpose: create a tag.
Usage: DOMDocument-> createElement_x_x (string name [, string value])
Parameter: name, label name, value, only;
Return value: a new DOMElement object. The failure value is false.
F. DOMDocument-> createTextNode ()
Purpose: create a text node.
Usage: DOMDocument-> createTextNode (string content)
Parameter: content, content;
Return value: a new DOMText object. The failure value is false.
H. DOMDocument-> createCDATASection ()
Purpose: Create a cdata node
Usage: DOMDocument-> createCDATASection (string data)
Parameter: data, content;
Return value: a new DOMCDATASection object. The failure value is false.
I. DOMDocument-> createAttribute ()
Purpose: create tag attributes.
Usage: DOMDocument-> createAttribute (string name)
Parameter: name, attribute name;
Return value: a new DOMAttr object. The failure value is false.
J. DOMDocument-> validate ()
Purpose: Test the xml code.
Usage: DOMDocument-> validate ()
Parameter: None
Return: if the operation succeeds, TRUE is returned. if the operation fails, FALSE is returned.
K. DOMDocument-> save ()
Purpose: save the xml code to the xml file.
Usage: DOMDocument-> save (string filename)
Parameter: filename, xml file;
Return: The xml character length is returned successfully. if the string fails, false is returned.
L. DOMDocument-> saveXML ()
Purpose: save the xml code.
Usage: DOMDocument-> saveXML ([DOMNode node [, int options])
Parameter: node, DOMNode;
Return: xml is returned for success, and false is returned for failure.
M, DOMElement-> hasAttribute ()
Purpose: check whether a property exists.
Usage: DOMElement-> hasAttribute (string name)
Parameter: name, attribute name;
Return: if the operation succeeds, TRUE is returned. if the operation fails, FALSE is returned.
N, DOMElement-> getAttribute ()
Purpose: get the property value.
Usage: DOMElement-> getAttribute (string name)
Parameter: name, attribute name;
Return: The property value is returned successfully. if the property value is returned, null is returned.
O, DOMElement-> getAttribute ()
Purpose: get the property value.
Usage: DOMElement-> getAttribute (string name)
Parameter: name, attribute name;
Return: The property value is returned successfully. if the property value is returned, null is returned.
P, DOMElement-> setAttribute ()
Purpose: Set the attribute value.
Usage: DOMElement-> setAttribute (string name, string value)
Parameter: name, attribute name; value, attribute value
Return: if the operation succeeds, TRUE is returned. if the operation fails, FALSE is returned.
Q, DOMNode-> appendChild ()
Purpose: link the child node to the parent node.
Usage: DOMNode-> appendChild (DOMNode newnode)
Parameter: newnode, new node;
Return: The node is returned successfully. if the node fails, null is returned.
R, DOMNode-> hasAttributes ()
Purpose: Check whether attributes exist.
Usage: DOMNode-> hasAttributes ()
Parameter: None
Return: if the operation succeeds, TRUE is returned. if the operation fails, FALSE is returned.
S, DOMNode-> hasChildNodes ()
Purpose: Check whether subnodes exist.
Usage: DOMNode-> hasChildNodes ()
Parameter: None
Return: if the operation succeeds, TRUE is returned. if the operation fails, FALSE is returned.
T, DOMNode-> insertBefore ()
Purpose: Insert the child node into the dom tree, which is located before a node.
Usage: DOMNode-> insertBefore (DOMNode newnode [, DOMNode refnode])
Parameter: newnode, new node; refnode, refer to node
Return: a new node is returned successfully. if the node fails, a blank value is returned.
U, DOMNode-> removeChild ()
Purpose: Delete a subnode.
Usage: DOMNode-> removeChild (DOMNode oldnode)
Parameter: oldnode, subnode;
Return: The child node is returned successfully. if the child node fails, null is returned.
V, DOMNode-> replaceChild ()
Purpose: update a subnode.
Usage: DOMNode-> replaceChild (DOMNode newnode, DOMNode oldnode)
Parameter: newnode, new node, oldnode, old node
Return: The oldnode is returned successfully. if the node fails, null is returned.
--------- DOMNode attribute -------------
A. DOMNode-> nodeType
Purpose: obtain the node type.
B. DOMNode-> nodeName
Purpose: Get the node name
C. DOMNode-> nodeValue
Purpose: Get node content
D. DOMNode-> textContent
Purpose: Get node content
E. DOMNode-> parentNode
Purpose: obtain the parent node of a node.
F. DOMNode-> childNodes
Purpose: obtain node subnodes.
G, DOMNode-> firstChild
Purpose: obtain the first subnode of a node.
H. DOMNode-> lastChild
Purpose: obtain the last subnode of a node.
2. XMLReader
A. XMLReader: XML
Purpose: load an xml string.
Usage: XMLReader: xml (string source [, string encoding [, int options])
Parameter: source, xml string; encoding, document encoding or NULL
Return: if the operation succeeds, TRUE is returned. if the operation fails, FALSE is returned.
B. XMLReader: open
Purpose: load an xml file.
Usage: XMLReader: open (string url [, string encoding [, int options])
Parameter: url, link to xml; encoding, document encoding or NULL
Return: if the operation succeeds, TRUE is returned. if the operation fails, FALSE is returned.
C. XMLReader: read
Purpose: read xml to forward the parser to the next tag.
Usage: XMLReader: read (), traversing the entire document in the while loop
Parameter: NULL
Return: if the operation succeeds, TRUE is returned. if the operation fails, FALSE is returned.
D. XMLReader: getAttribute
Purpose: Get attributes
Usage: XMLReader: getAttribute (string name)
Parameter: name, attribute name
Return: if the operation succeeds, the property value is returned. if the operation fails, FALSE is returned.
E. XMLReader: isValid
Purpose: Check whether xml is legal
Usage: XMLReader: isValid ()
Parameter: None
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
F. XMLReader: moveToAttribute
Purpose: move the focus to the attribute.
Usage: XMLReader: moveToAttribute (string name)
Parameter: name, attribute name
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
G, XMLReader: moveToFirstAttribute
Purpose: move the focus to the first attribute.
Usage: XMLReader: moveToFirstAttribute ()
Parameter: None
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
H. XMLReader: moveToNextAttribute
Purpose: move the focus to the next attribute.
Usage: XMLReader: moveToNextAttribute ()
Parameter: None
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
I. XMLReader: moveToElement
Purpose: move the focus to the current attribute of the parent node.
Usage: XMLReader: moveToElement ()
Parameter: None
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
J. XMLReader: close
Purpose: disable xml input.
Usage: XMLReader: close ()
Parameter: None
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
-------- Constant ---------
XMLReader: NONE = 0;
XMLReader: ELEMENT = 1;
XMLReader: ATTRIBUTE = 2;
XMLReader: TEXT = 3;
XMLReader: CDATA = 4;
XMLReader: ENTITY_REF = 5;
XMLReader: ENTITY = 6;
XMLReader: PI = 7;
XMLReader: COMMENT = 8;
XMLReader: DOC = 9;
XMLReader: DOC_TYPE = 10;
XMLReader: DOC_FRAGMENT = 11;
XMLReader: NOTATION = 12;
XMLReader: WHITESPACE = 13;
XMLReader: SIGNIFICANT_WHITESPACE = 14;
XMLReader: END_ELEMENT = 15;
XMLReader: END_ENTITY = 16;
XMLReader: XML_DECLARATION = 17;
XMLReader: LOADDTD = 1;
XMLReader: DEFAULTATTRS = 2;
XMLReader: VALIDATE = 3;
XMLReader: SUBST_ENTITIES = 4;
-------- Properties -----------
A. XMLReader-> attributeCount;
Role: number of attributes
B. XMLReader-> baseURI;
Role: node url
C. XMLReader-> depth;
Role: number of layers of the node tree
D. XMLReader-> hasAttributes;
Purpose: check whether any attribute exists.
E. XMLReader-> hasValue;
Role: whether there is a value
F. XMLReader-> isEmptyElement;
Purpose: whether the tag is empty.
G, XMLReader-> localName;
Role: label description
H. XMLReader-> name;
Role: Tag name
I. XMLReader-> nodeType;
Role: node type
J. XMLReader-> value;
Purpose: content of the node text
3. XMLWriter
A. XMLWriter: openURI
Purpose: Create an XMLWriter from the url output code.
Usage: XMLWriter: openURI (string uri)
Parameter: url xml address
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
B. XMLWriter: setIndentString
Purpose: set indentation characters.
Usage: XMLWriter: setIndentString (string indentString)
Parameter: indentString indent character
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
C. XMLWriter: setIndent
Purpose: Set the indent switch.
Usage: XMLWriter: setIndent (bool indent)
Parameter: indent or not
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
D. XMLWriter: startDocument
Purpose: Set the document start tag.
Usage: XMLWriter: startDocument ([string version [, string encoding [, string standalone])
Parameter: version, version, encoding, encoding, standalone, Independent
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
E. XMLWriter: endDocument
Purpose: Set the document end tag.
Usage: XMLWriter: endDocument ()
Parameter: None
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
F. XMLWriter: startDTD
Purpose: Set the dtd start tag.
Usage: XMLWriter: startDTD (string qualifiedName [, string publicId [, string systemId])
Parameter: qualifiedName, name; publicId, piublic; systemId, system
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
G, XMLWriter: endDTD
Purpose: Set the dtd end tag.
Usage: XMLWriter: endDTD ()
Parameter: None
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
H. XMLWriter: startElement
Purpose: set the start tag.
Usage: XMLWriter: startElement (string name)
Parameter: name, label name
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
I. XMLWriter: endElement
Purpose: set the end tag.
Usage: XMLWriter: endElement ()
Parameter: None
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
J. XMLWriter: startCData
Purpose: set the start tag.
Usage: XMLWriter: startCData ()
Parameter: None
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
K. XMLWriter: endCData
Purpose: set the end tag.
Usage: XMLWriter: endCData ()
Parameter: None
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
L. XMLWriter: writeAttribute
Purpose: write tag attributes.
Usage: XMLWriter: writeAttribute (string name, string value)
Parameter: name, attribute name; value, attribute value
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
M, XMLWriter: writeElement
Purpose: write tag attributes.
Usage: XMLWriter: writeElement (resource xmlwriter, string name, string content)
Parameter: xmlwriter, xml Resource; name, tag name; value, text value
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
N, XMLWriter: writeCData
Purpose: write tag attributes.
Usage: XMLWriter: writeCData (resource xmlwriter, string content)
Parameter: xmlwriter, xml Resource; value, text value
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
O, XMLWriter: text
Purpose: write text
Usage: XMLWriter: text (string content)
Parameter: content, text value
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
P, XMLWriter: flush
Purpose: clear cache
Usage: XMLWriter: flush ()
Parameter: None
Return: if the operation succeeds, true is returned. if the operation fails, FALSE is returned.
Functions of functions a and DOMDocument-load (): loads xml files. usage: DOMDocument-load (string filename) parameter: filename, xml file; return: TRUE if successful, missing...