Jump to content

XML: Simple, how to get a value?


Recommended Posts

You'd think this would be simple, but it isn't.

<node1>
    <node2 name="adam"/>
</node1>

All I want to do, is use the XML DOM wrapper to get the atomic value "adam". How in the world is this done? I've tried:

_XMLGetAttrib("node1/node2", "name")

_XMLGetField("node1/node2/name")

_XMLGetValue("node1/node2/name")

None of these return valid input.

If I use:

Dim $sNames[1]
Dim $sVals[1]
_XMLGetAllAttrib("node1/node2", $sNames, $sVals)
_ArrayDisplay($sNames)
_ArrayDisplay($sVals)

$sNames and $sVals are properly filled, and I could do a search in $sNames for "name", get the index and match it up with the value in $sVals under the same index. But we all know this isn't the right way to do it. How is it done?

EDIT: GOT IT. Apparently I need a foreslash before the first node like _XMLGetAttrib("/node1/node2", "name"). This isn't required in some of the other functions.

Edited by Decker87
Link to comment
Share on other sites

You'd think this would be simple, but it isn't.

<node1>
    <node2 name="adam"/>
</node1>

All I want to do, is use the XML DOM wrapper to get the atomic value "adam". How in the world is this done? I've tried:

_XMLGetAttrib("node1/node2", "name")

_XMLGetField("node1/node2/name")

_XMLGetValue("node1/node2/name")

None of these return valid input.

If I use:

Dim $sNames[1]
Dim $sVals[1]
_XMLGetAllAttrib("node1/node2", $sNames, $sVals)
_ArrayDisplay($sNames)
_ArrayDisplay($sVals)

$sNames and $sVals are properly filled, and I could do a search in $sNames for "name", get the index and match it up with the value in $sVals under the same index. But we all know this isn't the right way to do it. How is it done?

EDIT: GOT IT. Apparently I need a foreslash before the first node like _XMLGetAttrib("/node1/node2", "name"). This isn't required in some of the other functions.

Hey,

Thanks for letting us know that you got it, and also telling how you fixed it. Great contribution. Also, just for sake of being uniform, I would include the slash before on all of the functions as this way everything is fully defined. It knows you want to start from the root and follow the tree you have described.

Thanks again,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

No problem. Generally, I can find all the info I need in the documentation - but there is no UDF documentation for the XML DOM Wrapper yet, just brief descriptions in the file itself. Examples are about 1000% more helpful than anything else. When I'm done with my project I will try to remember to post it.

Edited by Decker87
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...