Thanks Robert and Brian,
As you pointed out, having a default namespace was the issue. However it took
me awhile to work out that the nsMap parameter of the Locate statement can't
have quotes around the uri. Once I had (accidently) discovered that, the
xdomlocate function worked.
include UNIVERSE.INCLUDE XML.H
xml = '<?xml version="1.0" ?>'
xml := '<ABRPayloadSearchResults xmlns="http://tempuri" >'
xml := '<response>'
xml := '<exception>Exception Message</exception>'
xml := '</response>'
xml := '</ABRPayloadSearchResults>'
* !! nsmap = 'xmlns:a="http://tempuri"' Does Not Work with quoted "uri" !!
nsmap = 'xmlns:a=http://tempuri'
xpathStr = '/a:ABRPayloadSearchResults/a:response/a:exception'
if xdomopen(xml,XML.FROM.STRING,hd) # XML.ERROR then
if xdomlocate(hd,xpathStr,nsmap,hn) # XML.ERROR then
if not(xdomgetnodename(hn,name)) and name[9] = 'exception' then
crt 'Located ':name
end
end
end
Many thanks,
Stuart Boydell
-----Original Message-----
Beware of default namespaces. If you have one defined, then XPath needs to have
a namespace mapped to a dummy prefix, and you have to qualify the prefix. The
following can be referenced using "/x/y".
<x><y>something...
But this has a problem:
<x xmlns="foo"><y>something...
Internally, XML tracks this like "/{foo}:x/{foo}:y". What you have to do is
tell the XPath processor to map some prefix, say 'a' to the namespace 'foo',
then use "/a:x/a:y".
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users