我正在尝试将XML节点附加到IE< 8中的HTML DOM中,并且我不断收到Object doesn't support property or method appendChild
错误,但在最新的浏览器上工作正常。是否有另一种在DOM中附加XML元素的方法?
我也尝试过<meta http-equiv="X-UA-Compatible" content="IE=8">
var jObj = { "Smart Shoes":{
"Product":"Smart Shoes",
"Price":24.99,
"Quantity":"1x "
},
"Denim Jeans":{
"Product":"Denim Jeans",
"Price":30,
"Quantity":"1x "
}
};
var xml = document.createElement("xml");
xml.setAttribute("id", "POSCMD");
xml.setAttribute("LateProcessing", "true");
var commands = document.createElement("commands");
xml.appendChild(commands);
var injFM = document.createElement("injectfieldmacro");
injFM.setAttribute("type", "field");
injFM.setAttribute("name", "FIELD_CLEAR");
commands.appendChild(injFM);
var injData;
for (var item in jObj) {
injData = document.createElement("injectdata");
injData.setAttribute("type", "literal");
injData.setAttribute("data", JSON.stringify(jObj[item].Product));
injFM = document.createElement("injectfieldmacro");
injFM.setAttribute("type", "field");
injFM.setAttribute("name", "FIELD_UPC");
commands.appendChild(injData);
commands.appendChild(injFM);
}
document.getElementsByTagName("body")[0].appendChild(xml);