I have a XML:
<Name id="Name" dataType="java.lang.String" perDataProId="">Peter</Name>
<Grid1 id="Grid1">
<records>
<record id="Grid1_0">
<item id="department" dataType="java.lang.String" perDataProId="">PUR</item>
</record>
<record id="Grid1_1">
<item id="department" dataType="java.lang.String" perDataProId="">SALE</item>
</record>
</records>
</Grid1>
I can get the Name tag text using:
if (dom.getElementsByTagName("Name").length!=0){
name= dom.getElementsByTagName("Name")[0].childNodes[0].nodeValue;
}
but how to get the item department's value? I have tried dom.getElementsByTagName("Grid1_0").length
and the result is 0. Can anyone help me with this ?
在这种情况下,您可以使用getElementById通过id获取元素,即:
dom.getElementById('Grid1_0')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.