1 回答
TA贡献1862条经验 获得超6个赞
原因是节点 Std、Virtual、Key 等附加到 rootElement 而不是 NewInstance_node
详细:
var doc = document.implementation.createDocument(null, null);
var rootElement = doc.createElement("Service");
var NewInstance_node = doc.createElement("NewInstance");
var attr = doc.createAttribute("ref");
attr.value="External_UCSD_Serverinfo";
NewInstance_node.setAttributeNode(attr);
rootElement.appendChild(NewInstance_node);
var Std_node = doc.createElement("Std");
Std_node.appendChild(doc.createTextNode("DiscoveredElement"));
NewInstance_node.appendChild(Std_node);
var Std_Virtual = doc.createElement("Virtual");
NewInstance_node.appendChild(Std_Virtual);
var Key_node = doc.createElement("Key");
Key_node.appendChild(doc.createTextNode("Key001"));
NewInstance_node.appendChild(Key_node);
var CIAttributes_node = doc.createElement("Attributes");
var CIAttribute_node1 = doc.createElement("Attribute");
var attr_name1 = doc.createAttribute("name");
attr_name1.value="hpom_citype";
var attr_val1 = doc.createAttribute("value");
attr_val1.value="External_UCSD_Serverinfo";
CIAttribute_node1.setAttributeNode(attr_name1);
CIAttribute_node1.setAttributeNode(attr_val1);
rootElement.appendChild(CIAttributes_node);
CIAttributes_node.appendChild(CIAttribute_node1);
doc.appendChild(rootElement);
添加回答
举报