Jump to content
Sign in to follow this  
josheee12

xml extraction

Recommended Posts

josheee12

i have xml with this format

<root><myitem id="123456789"><text>toothbrush</text></myitem></root>

how would i extract "toothbrush" using xmldomwrapper? i figured out how to get "123456789", but i cannot figure out how to extract text without a tag of some sort.

Share this post


Link to post
Share on other sites
weaponx

#include "_XMLDomWrapper.au3"

$sXMLFile = "test2.xml"

$result = _XMLFileOpen($sXMLFile)
If $result = 0 Then Exit

$value = _GetFirstValue("/root/myitem[@id='123456789']/text")
MsgBox(0,"",$value)

;Get the first real value returned from the _XMLGetValue() return array.
Func _GetFirstValue($node)
    $ret_val = _XMLGetValue($node)
    If IsArray($ret_val) Then Return ($ret_val[1])
    Return SetError(1,3,0)
EndFunc

Share this post


Link to post
Share on other sites
josheee12

#include "_XMLDomWrapper.au3"

$sXMLFile = "test2.xml"

$result = _XMLFileOpen($sXMLFile)
If $result = 0 Then Exit

$value = _GetFirstValue("/root/myitem[@id='123456789']/text")
MsgBox(0,"",$value)

;Get the first real value returned from the _XMLGetValue() return array.
Func _GetFirstValue($node)
    $ret_val = _XMLGetValue($node)
    If IsArray($ret_val) Then Return ($ret_val[1])
    Return SetError(1,3,0)
EndFunc

it returns

C:\scripts\api.au3 (27) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

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.