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
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn