...

<ITEM id="206"> Read-out ID-value

Jerome
04-03-2003, 10:28 AM
Hi,

Retrieving a xml-file and reading the nodeValues of the different Childs is working fine.

For future possibilities I added an id to every item.

My question is: how can I read-out the id-value of every item using the routine mentioned below?

Thanks for Your effort,
Jerome

XML-file:

<?xml version="1.0"?>
<PRODUCTS>
<ITEM id="206">
<MODEL>extra large</MODEL>
<YEAR>1990</YEAR>
</ITEM>
<ITEM id="207">
<MODEL>large</MODEL>
<YEAR>1991</YEAR>
</ITEM>
<ITEM id="208">
<MODEL>medium</MODEL>
<YEAR>1991</YEAR>
</ITEM>
<ITEM id="209">
<MODEL>small</MODEL>
<YEAR>2000</YEAR>
</ITEM>
</PRODUCTS>

Routine:

var cont=xmlDoc.documentElement.childNodes;

data="";
data+="<table>";
for(i=0;i<=cont.length-1;i++)
{
data+="<tr><td>ID-VALUE</td><td>"+cont[i].childNodes[k].text+"</td></tr>";
}
data+="</table>";

Alex Vincent
04-04-2003, 02:59 AM
Document Object Model, Level One:

"<tr><td>" + cont[i].childNodes[k].getAttribute("id") + "</td>..."

http://www.w3.org/tr/domhttp://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/

Jerome
04-04-2003, 01:52 PM
Thanks for Your effort Alex!

Ofcourse, it works fine

Jerome



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum