0

Apologies if this is worded incorrectly, I'm not sure of the correct terms when it comes to 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?

Many thanks in advance

leddy
  • 531
  • 3
  • 13
  • 31

2 Answers2

0

Attribute! That was the term i was looking for!

This is how I've done it:

.selectSingleNode('./itt_attachordersid').getAttribute('name');
leddy
  • 531
  • 3
  • 13
  • 31
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> 
user786
  • 3,902
  • 4
  • 40
  • 72