Stuart
This works for me:
$INCLUDE UNIVERSE.INCLUDE XML.H
XML = \<?xml version="1.0" ?>\
XML<-1> = '<ABRPayloadSearchResults>'
XML<-1> = '<first />'
XML<-1> = '<response>'
XML<-1> = '<exception>Some Exception</exception>'
XML<-1> = '</response>'
XML<-1> = '</ABRPayloadSearchResults>'
XML = Change(XML,@FM,Char(13):Char(10))
If XDOMOpen(XML,XML.FROM.STRING,hDOM) = XML.ERROR Then
Crt "Cannot open DOM "
STOP
End
GoSub Parse
Ok = XDOMClose(hDOM)
STOP
Parse:
* First get my context (ROOT tag)
If
XDOMLocate(hDOM,'/ABRPayloadSearchResults/response/exception',"",hNode) =
XML.ERROR Then
Crt "Cannot get element"
RETURN
End
Ok = XDOMGetNodeName(hNode,NodeName)
Crt "Node Name = ":NodeName
If XDOMLocateNode(hNode, XDOM.CHILD, XDOM.FIRST.CHILD,
XDOM.TEXT.NODE, hTextNode) <> XML.ERROR Then
ok = XDOMGetNodeValue(hTextNode, Value)
Crt "Value = ":Value
end
Return
Brian
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Boydell, Stuart
Sent: 20 May 2010 10:33 AM
To: U2 Users List
Subject: [U2] XPath queries
Is it just me being dull-witted or do XPath queries in XDOM not work by
name?
Linux UV 10.2.7
I have spent quite a few hours trying to get something working and the only
way I can get the node is to specify it by position rather than name.
For example I have to use this format to successfully query if an
'exception' element exists:
XDOMLocate(dh, '/*[1]/*[2]/*[last()]','',xh)
instead of specifying exactly what I'm looking for with what I believe
should be valid XPath:
XDOMLocate(dh, '/ ABRPayloadSearchResults/response/exception','',xh)
or even better:
XDOMLocate(dh, '//exception','',xh)
both of which return -1.
Anyone got any clues?
Cheers,
Stuart Boydell
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.819 / Virus Database: 271.1.1/2883 - Release Date: 05/19/10
19:26:00
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users