請幫我解決以下問題。Xml解析enyo框架的webos
問題是在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.The解析部分是在這裏:
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完整的文本內容是越來越diaplayed serially.how做我得到各個節點和兒童nodes.i我得到空值所有這些.PLease幫助一些代碼示例。
謝謝:)