Xmlreader question

I have a xml file with the following content :

<?xml version="1.0" ?>
<books>
<book>
<price> "44.95" </price>
<title>Core Java 1.5</title>
<author>Piet  Klerksenc </author>
<nrPages>1487</nrPages>
</book>
<book>
<price> "59.95" </price>
<title>Developing with Servoy</title>
<author>Cheryl Owens and others</author>
<nrPages>492</nrPages>
</book>
</books>

It displays oke in internet explorer.
I try to read it using the following method.

var xmlNode= plugins.XmlReader.readXmlDocumentFromFile('c:/abc.xml');

var attributeNames = xmlNode[0].getAttributeNames();

for(i = 0; i < attributeNames.length; i++)
{
currAttributeName = attributeNames[i];
currAttributeValue = xmlNode.getAttributeValue(currAttributeName);
application.output(currAttributeName + ": " + currAttributeValue);
}

The value of attributeNames.length is 0 so the attribute names are not read properly.

Anyone any idea of what i am doing wrong ?

I know what you are doing wrong: you are not using our excellent XML-Plugin! :lol:

has no attributes, that’s why length results in 0. What you want is not attributes, but children (elements).

As Patrick already said you don’t have attributes in your nodes. You have only childnodes and text.
So you need to use the getChildNodes and getTextValue functions.

Hope this helps.

Thank you Guys,

As always, the support from the forum is great !!!

There where several people on Sw2007 who said that this is
one of the very strong features of Servoy.

And they are right !!!

@Patrick : At this moment i am just playing around with Xml.
When i am going to build a production system involving
Xml I will for sure look at your plugin

Regards,