The code copy is as follows:
// Delete all children before adding children
var usernameEle = document.getElementById("username");
var children = usernameEle.childNodes;
for(var i = children.length - 1; i >= 0; i--) {
usernameEle.removeChild(childs[i]);
}
var username = document.createTextNode(obj.username);
usernameEle.appendChild(username);
property:
nextSibling returns the next sibling node of the current node (read-only)
previousSibling returns the previous sibling node of this node (read-only)
parentNode returns the parent node (read-only)
childNodes The child node list of storage nodes (read-only)
nodeValue Returns the text of the node (readable and writeable)
Text Returns the text content of this node and its descendants (readable and writeable)
nodeName Returns the name of the node (read-only)
Attributes List of attributes for storage nodes (read-only)
dataType Returns the data type of this node
Definition Definition of nodes given in DTD or XML schema (read-only)
Doctype Specifies the document type node (read-only)
documentElement Returns the root element of the document (readable and writeable)
firstChild Returns the first child node of the current node (read-only)
Implementation Returns XMLDOMImplementation object
lastChild returns the last child node of the current node (read-only)
nodeType Returns the type of the node (read-only)
nodeTypedValue stores node value (readable and writeable)
ownerDocument Returns the root document containing this node (read-only)
Parsed Returns whether this node and its children have been parsed (read-only)
Prefix returns namespace prefix (read-only)
preserveWhiteSpace Specifies whether to keep blanks (readable and writeable)
url Returns the URL of the recently loaded XML document (read-only)
Xml returns the XML representation of the node and its descendants (read-only)
method:
getElementsByTagName Returns the set of elements of the specified name
appendChild Add a new child node to the current node and place it after the last child node
createElement Create an element node
createTextNode Creates a text node that includes the given data
removeChild Remove specified child node from child node list
hasChildNodes Returns whether there are children in the current node
cloneNode returns the copy of the current node
createAttribute Create new attribute
createCDATASection Creates a CDATA segment that includes the given data
createComment Create a comment node
createDocumentFragment Creates DocumentFragment object
createEntityReference Create an EntityReference object
createNode Creates nodes for a given type, name and namespace
createPorcessingInstruction Create an operation command node
insertBefore Insert child nodes before specified node
Load Imports XML documents at the specified location
loadXML Import XML document of the specified string
replaceChild Replace the specified child node from the child node list
Save Save XML file to the specified node
selectNodes Makes a specified match to the node and returns the matching node list
selectSingleNode makes a specified match to the node and returns the first matching node
transformNode converts nodes and their descendants using the specified stylesheet
transformNodeToObject converts nodes and their descendants into objects using the specified stylesheet