Js traversal of subnode child elements
Js traversal of subnode child elements
Method for attributes of subelements of Js nodes
// Delete all child nodes before adding a child node
Var usernameEle = document. getElementById ("username ");
Var childs = usernameEle. childNodes;
For (var I = childs. length-1; I> = 0; I --){
UsernameEle. removeChild (childs [I]);
}
Var username = document. createTextNode (obj. username );
UsernameEle. appendChild (username );
Attribute:NextSibling returns the next sibling node of the current node (read-only)
Previussibling returns the previous sibling node of this node (read-only)
ParentNode returns the parent node (read-only)
List of child nodes of the childNodes storage node (read-only)
NodeValue returns the node text (read/write)
Text returns the Text content of the node and its descendants (read/write)
NodeName: return the node name (read-only)
Attributes storage node attribute list (read-only) dataType returns the Data Type Definition of this node Definition in DTD or XML mode (read-only) Doctype specified file type node (read-only) documentElement returns the root element (read/write) of the document. firstChild returns the first child node (read-only) of the current node. Implementation returns the XMLDOMImplementation object. lastChild returns the last child node (read-only) of the current node) nodeType return node type (read-only) nodeTypedValue storage node value (read/write) ownerDocument returns the root document containing this node (read-only) parsed returns whether the node and Its subnodes have been resolved (read-only) Prefix returned namespace Prefix (read-only) preserveWhiteSpace specified whether to retain blank (read/write) the url returns the URL (read-only) XML of the recently loaded Xml document and the XML Representation of the node and its descendants (read-only)
Method:
GetElementsByTagName returns the set of elements with the specified name.
AppendChild adds a new sub-node to the current node, put it in the end of the sub-node, createElement creates an element node
CreateTextNode: Create a text node that includes the given data
RemoveChild deletes a specified subnode from the subnode list.
HasChildNodes: returns whether the current node has subnodes.
CloneNode returns the copy of the current node createAttribute create new attribute createCDATASection create CDATA segment including the given data createComment create a comment node createDocumentFragment create DocumentFragment object createEntityReference create EntityReference object createNode create a given type, name and namespace node createPorcessingInstruction create operation command node insertBefore insert sub-node Load import before the specified node XML document loadXML import specified string XML document replaceChild replace specified from the sub-node list the sub-node Save saves the XML file to the specified node selectNodes to match the specified node, return the matched node list selectSingleNode to match the specified node, the first matching node transformNode is returned. The node and its descendants are converted using the specified style table. transformNodeToObject: the node and its descendants are converted to objects using the specified style table.