I’m using the YQL Console to experiment with querying a REST XML web-service.
I found a simple public service to play with.
http://www.thomas-bayer.com/sqlrest/CUSTOMER/-151612345/
returns
<CUSTOMER xmlns:xlink="http://www.w3.org/1999/xlink">
<ID>-151612345</ID>
<FIRSTNAME>Deepthi</FIRSTNAME>
<LASTNAME>Deep</LASTNAME>
<STREET>440 - 20th Ave.</STREET>
<CITY>Los Angeles</CITY>
</CUSTOMER>
If I use the query:
select *
from xml
where url='http://www.thomas-bayer.com/sqlrest/CUSTOMER/-151612345/'
I get this XML returned. However, if I try to restrict to data to a single element, e.g.:
select *
from xml
where url='http://www.thomas-bayer.com/sqlrest/CUSTOMER/-151612345/'
and xpath='//LASTNAME'
no results are returned.
What am I doing wrong?
Click here to display the YQL console with the query loaded.
The correct key for filtering the results as you want is not
xpath, instead it isitemPath.(Try this query in the YQL console)
You can see the keys for a given table by issuing the query
desc <tablename>.(Try this query in the YQL console)
In the case of the
xmltable, theitemPathcan either be an XPath expression or an E4X dotted path.