页面ext与xml

// 根据xml创建dom对象
function loadXMLString(xmlString) {
  var xmlDoc = null;
  try {
    var parser = new DOMParser();
    xmlDoc = parser.parseFromString(xmlString, "text/xml");
  } catch (e) {
    xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.loadXML(xmlString);
  }
  return xmlDoc;
}

/**
* 组织成例子grid3一样的数据其中为json格式,然后需要eval作为Store的data
*/
function getStoreData(xmlStr) {
var xmlDoc = loadXMLString(xmlStr);
var returnStr = "[";
var con = xmlDoc.getElementsByTagName("relation");
for (var i = 0; i < con.length; i++) {
var relation = con[i];
returnStr += "[";
var relationChilds = relation.childNodes;
for (var j = 0; j < 5; j++) {
var relationChild = relationChilds[j];
returnStr += "'";
returnStr += relationChild.text;
returnStr += "'";
if (j != 4) {
returnStr += ",";
}
}
returnStr += "]";
if (i != (con.length - 1))
returnStr += ",";
}
returnStr += "]";
return returnStr;
}

你可能感兴趣的:(json,xml,ext,Microsoft,J#)