Jump to content
Sign in to follow this  

Trouble with XML-reading UDF

Recommended Posts



This UDF seems to be what I am looking for. I downloaded it and included it in my script.

I am trying to read information and write information to and from an XML file.

I need to get the "next" value from my <list> node. I don't know how to do that.

I also need to get the Name of the person from the <item> node.

I am trying to do that using this code snippet:

$sFile= "Admin\Tel\Tel.xml"

$ret = _XMLFileOpen ($sFile)

if $ret =0 then

MsgBox(4096, "File Open Error", "Error Opening File. Exiting program")



$attr=_XMLGetAttrib("/list/item", "Nom")

MsgBox(0, "NAME", $attr)

This is how my xml file looks like

<?xml version="1.0" encoding="windows-1252"?>

<list next="566" timestamp="3981" schemastamp="23">

<Schema next="15">

<ElementType name="item">

<element id="s1" type="id" display="No"/>

<!-- must have an id on every row -->

<element id="s2" type="Name" display="Yes" values=""/>

<element id="s3" type="Gname" display="Yes" values=""/>

<element id="s4" type="Ext1" display="Yes" values=""/>

<element id="s5" type="Ext2" display="Yes" values=""/>

<element id="s6" type="Notes" display="Yes" values=""/>

<element id="s7" type="Dept" display="Yes" values=""/>

<element id="s8" type="Dept2" display="No" values=""/>

<element id="s9" type="Keyword" display="No" values=""/>

<element id="s10" type="temp" display="No" values=""/>

<element id="s11" type="LoginName" display="Yes" values=""/>


















[EDIT - Added on October 24 2008] - I forgot to mention that I do not get any error when I do this, but the output in the message box is just empty. I don't really know why. It would mean that there is no such entry in the XML file or that it is not reading properly (which means I am not coding it properly).

If anyone knows what I am missing, I'd truly appreciate.



Share this post

Link to post
Share on other sites

I haven't really messed with XML files much, but I wanted to try to help out.

If you use _SetDebug(True), you'll see this error:

End tag 'GName' does not match the start tag 'Gname'.
This tells me it's case sensitive.

After changing 'GName' to 'Gname', this code worked for me:

if IsArray($attr) then MsgBox(0, "NAME", $attr[1])

btw, there are dozens of XML-related UDFs out there. Please link the source whenever you're requesting help.

Since you also posted this there, the UDF you're using is located here (for anyone who wants to help out)

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.