浏览 1751 次
锁定老帖子 主题:页面ext与xml
该帖已经被评为新手帖
|
|
---|---|
作者 | 正文 |
发表时间:2008-09-27
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; } 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |