请帮我解决以下问题。
问题在于 xml 解析我的 xml 代码是:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root type="object">
<codeListValue type="object">
<personnelCategory type="array">
<item type="string">Regular</item>
<item type="string">International</item>
<item type="string">Contractor</item>
<item type="string">System</item>
<item type="string">Employee</item>
</personnelCategory>
<pcImages type="array">
<item type="string">Windows</item>
<item type="string">Linux</item>
<item type="string">MAC OS</item>
<item type="string">Engineering Image</item>
</pcImages>
</codeListValue>
</root>
解析代码和web os sdk中的一样。解析部分在这里:
parseXML: function() {
this.items = [];
//this.path="/root";
this.url='Values.xml';
this.$.getGoogleResults.url = this.url;
this.$.getGoogleResults.call();
},
... ... gotResultsSuccess:函数(inSender,inResponse){
var xmlstring = inResponse;
var parser = new DOMParser();
var xmlobject = parser.parseFromString(xmlstring, "text/xml");
var nodes = document.evaluate('/root', xmlobject, null, XPathResult.ANY_TYPE, null);
var result = nodes.iterateNext();
//alert(result.textContent);
var i=0;
while(result)
{
this.items[i] = result.childNodes[0].nodeValue;
i++;
result=nodes.iterateNext();
}
this.items=result.textContent;
this.$.header.setContent(this.items);// [ this is a header component i have defined and i am setting its content here]
},
我得到了作为常规国际承包商系统的结果......工程形象
XML 中的完整文本内容正在连续显示。我如何获取单个节点和子节点。我得到所有这些的空值。请帮助提供一些代码示例。
谢谢 :)