Apologies if this is worded incorrectly, I'm not sure of the correct terms when it comes to xml.
如果措辞不正确,我很抱歉,我不确定xml的正确用语。
Basically, I have the following:
基本上,我有以下几点:
<result>
<createdon date="21/04/2015" time="14:52">2015-04-21T14:52:16+01:00</createdon>
<itt_attachordersid name="1699" dsc="0">{C95D9F0D-55EE-E411-A8CC-00505696BEC2}</itt_attatchordersid>
<itt_initialcost formattedvalue="£137.50">137.5</itt_initialcost>
<itt_instructionpurchasedforid name="1036490" dsc="0">{E3867EAA-78AC-E411-905E-00505696BEC2}</itt_instructionpurchasedforid>
<itt_jobnumber>EVO1036490</itt_jobnumber>
<itt_purchaseorderid>{3A9FE49B-2DE8-E411-A8CC-00505696BEC2}</itt_pruchaseorderid>
<transactioncurrencyid name="UK Pound Sterling" dsc="0">{78CD0E39-0E9C-E011-BCB5-001517A81D9D}</transactioncurrencyid> </result> <result>
I can get the value of each one using:
我可以使用以下方法获取每个值的值:
selectSingleNode('./itt_initialcost').nodeTypedValue;
But I want to get the parts/elements (?) within as well, so name and dsc in itt_attachordersid for example. How do I go about that please?
但是我想要获取部件/元素(?),例如itt_attachordersid中的name和dsc。我该怎么办呢?
Many thanks in advance
提前谢谢了
2 个解决方案
#1
0
Attribute! That was the term i was looking for!
属性!这就是我一直在寻找的术语!
This is how I've done it:
这就是我做到的方式:
.selectSingleNode('./itt_attachordersid').getAttribute('name');
#2
0
Here is an example for you
这是一个例子给你
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book');
for (i=0;i<x.length;i++)
{
document.write(x[i].getAttribute('time'));
document.write("<br>");
}
XML file
<sports>
<game time="day">
...
</game>
</sports>
#1
0
Attribute! That was the term i was looking for!
属性!这就是我一直在寻找的术语!
This is how I've done it:
这就是我做到的方式:
.selectSingleNode('./itt_attachordersid').getAttribute('name');
#2
0
Here is an example for you
这是一个例子给你
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book');
for (i=0;i<x.length;i++)
{
document.write(x[i].getAttribute('time'));
document.write("<br>");
}
XML file
<sports>
<game time="day">
...
</game>
</sports>