Copy Code code as follows:
function getXml () {
Get input value
var name = Textname.getvalue ();
var pwd = Textpwd.getvalue ();
Initializing objects
var xmldoc = document.implementation.createDocument ("", "", null);
Xmldoc.async= "false";//Cancel the action submitted by the XML without completing the complete completion of the data
XML Header Authoring
var header=xmldoc.createprocessinginstruction ("xml", "version= ' 1.0");
Xmldoc.appendchild (header);
To create a child tree
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);
Kishuven This content is mounted
Username.appendchild (Usernametext);
Userpassword.appendchild (Passwordtext);
Child tree Node mount
Root.appendchild (username);
Root.appendchild (UserPassword);
Root content Mount
Xmldoc.appendchild (root);
return XML text content
return xmldoc;
};
I use
Copy Code code as follows:
var dom= new ActiveXObject ()
Only IE can run, in order to be compatible, must consider Firefox users, so, this program for: Firefox user compatibility; no local XML can be generated dynamically