Yuck! That sounds like a bug to me. Anywhere else, the quotes would be mandatory.
Always glad to help! Default namespaces have always felt like a bad compromise to me... -----Original Message----- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Boydell, Stuart Sent: Thursday, May 20, 2010 10:48 PM To: U2 Users List Subject: Re: [U2] XPath queries 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 U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users _______________________________________________ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users