Guy's,

I'm trying to read an XML file with the code below. Unfortunately I get no results. All variables are empty. We have the same code in a different script that also reads an XML file and it works great. The XML encoding on both files is the same. Anyone got some bright ideas on this?

 Code:
Break on
Call @scriptdir + "\functions\LoadXML().udf"
Call @scriptdir + "\functions\ReadXMLValue().udf"

$xml = LoadXml(@SCRIPTDIR + "\test.xml")

$id = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/id")
$name = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/name")
$gender = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/gender")
$age = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/age")
$place = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/place")
$province = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/province")
$date_membership = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/date_membership")
$url_profile = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/url_profile")
$url_photothumb = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/url_photothumb")
$advert_title = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/advert_title")
$advert_description = ReadXmlValue($xml, "stuff/morestuff" + $index2 + "/advert_description")

?$id
?$name
?$gender
?$age
?$place
?$province
?$date_membership
?$url_profile
?$url_photothumb
?$advert_title
?$advert_description
Sleep 10


LoadXML UDF:
 Code:
Function LoadXml($filename)

Dim $, $rootNode
$loadXml = CreateObject("Microsoft.XMLDOM");
If Not $loadXml
	Return
EndIf

$= $loadXml.Load($filename)

EndFunction


ReadXMLValue UDF:
 Code:
Function ReadXmlValue($xml, $key, optional $defaultValue)

Dim $sectionNode
$sectionNode = $xml.SelectSingleNode($key);
If Not $sectionNode
	$ReadXmlValue = $defaultValue
Else
	$ReadXmlValue = $sectionNode.FirstChild.Text;
EndIf

EndFunction


XML File:
 Quote:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<stuff>
<morestuff>
<id>34538</id>
<name>name</name>
<gender>Male</gender>
<age>29</age>
<place>Amsterdam</place>
<province>Noord Holland</province>
<date_membership>18-april-2007</date_membership>
<url_profile>http://somesite</url_profile>
<url_photothumb>http://somesite.nl/someimage.jpg</url_photothumb>
<advert_title>Title</advert_title>
<advert_description>Description</advert_description>
</morestuff>
</stuff>


Edited by Mart (2007-04-20 10:17 AM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.