Xpath problem
January 28, 2005 7:16 AM   Subscribe

XPATH hell-I'm trying to XPATH out the (xml) contents of the processVXMLReturn tag in this document. The file contains the exact XML response from a web service; I have no control over the output. I'm just interested in the nested xml payload. Hope my terminology is correct.[M to the Izzay]

Positive Oracle karma offered in exchange!

I'm making an PL/SQL call to a web service; the web service returns an xml document within the main xml document. I need to separate the envelope from the payload. From there, I'll extract the other elements. If my terminology stinks, please correct me.
posted by neilkod to Computers & Internet (13 answers total)
 
Don't you just want "/*/*" for the XPath query? Perhaps I've misunderstood what you want?
posted by brool at 8:11 AM on January 28, 2005


/processVXMLResponse/processVXMLReturn will point to the node in question. However, you'll have to unescape the markup in the 'payload' document.
posted by IshmaelGraves at 8:12 AM on January 28, 2005


Response by poster: IshmaelGraves, thanks - I've tried that and it came back as NULL for whatever reason. I'm wondering if all that xmlns="" and xsi:type mumbo jumbo mean anything.
posted by neilkod at 8:15 AM on January 28, 2005



/processVXMLResponse/processVXMLReturn
is right. The xmlns="" is saying this document is in the default namespace. The xsi:type stuff is saying that the contents of your node are an XML Schema string. Neither of those should interfere with XPath.
posted by Nelson at 8:37 AM on January 28, 2005


neilkod, it shouldn't return NULL. What language or API are you using to parse the XPath? Have you tried brool's? '/*/*' should work also.
posted by IshmaelGraves at 8:48 AM on January 28, 2005


is that all there is, or have you just posted a fragment? shouldn't it have an "xml" element around it (like the one encoded in the payload)?
posted by andrew cooke at 8:56 AM on January 28, 2005


Of course andrew cooke is right. If this is all you've got, an XPath probably won't work since any API call to evaluate an XPath is going to use some sort of XML parser, which will choke on this since it isn't XML. It needs something like this at the beginning:

<?xml version="1.0"?>
posted by IshmaelGraves at 9:00 AM on January 28, 2005


Response by poster: ok folks, i got it. I'm using Oracle's xmltype.extract function. The problem was that I wasn't specifying the (empty) namespace for the processVXMLResponse tag. This was difficult!

The end result looked like this

select xmltype.getstringval(xmltype.extract(response,'//processVXMLResponse/processVXMLReturn/text()','xmlns=""')) q from neiltest where id=177243

the ,xmlns="" passed into the extract function was what made the difference
posted by neilkod at 9:26 AM on January 28, 2005


does that mean that there's a default namespace (ie that "" isn't the default)? i hate xml namespaces... :o(
posted by andrew cooke at 9:36 AM on January 28, 2005


Response by poster: andrew cooke, for what its worth, having the xmlns="" is NOT the same as having no namespace. That's what did it.
posted by neilkod at 9:52 AM on January 28, 2005


thanks. that's what i meant (if you mean "not the same" wrt the spec, rather than just some weird implementation you're using). in which case, it looks like an error in whatever is generating the xml, since i'd put money on "them" thinking that's what it meant.
posted by andrew cooke at 11:12 AM on January 28, 2005


I've always enjoyed using the tool XPath Visualizer for simple tests as to whether an xpath expression will match a node.

Unfortunately, I can't help you with Oracle-specific questions.
posted by matildaben at 1:27 PM on January 28, 2005


andrew cooke, for what its worth, having the xmlns="" is NOT the same as having no namespace. That's what did it.

Wow, really? My bad. So, um, how do you explicitly specify "no namespace"?
posted by Nelson at 3:42 PM on January 28, 2005


« Older Can I be physically/sexually allergic to someone?   |   Upgrading my Mac's memory and video card Newer »
This thread is closed to new comments.