function getXml() {
//Get the input value
var name = textName.getValue();
var pwd = textPwd.getValue();
//Initialization object
var xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.async="false";//Cancel the action of submitting xml before the data is completely filled in
//Xml header writing
var header=xmlDoc.createProcessingInstruction("xml ","version='1.0'");
xmlDoc.appendChild(header);
//Create subtree
var root = xmlDoc.createElement("loginInfo");
var username = xmlDoc.createElement("userName");
var userpassword = xmlDoc.createElement("passWord");
//Create subtree text content
var usernameText=xmlDoc.createTextNode(name);
var passwordText=xmlDoc.createTextNode(pwd);
//Subtree text content mounting
username.appendChild(usernameText);
userpassword.appendChild(passwordText);
//Subtree node mounting
root.appendChild(username);
root.appendChild(userpassword);
//Root content mounting
xmlDoc. appendChild(root);
//Return xml text content
return xmlDoc;
};
I use
var dom= new ActiveXObject()
Only IE can run it. For compatibility, Firefox users must be considered, so this program is for: compatibility for Firefox users; it can be dynamically generated without local XML