2011-10-19 2 views
1

YQL Console을 사용하여 REST XML 웹 서비스를 쿼리하는 방법을 실험하고 있습니다.YQL을 사용하여 XML 서비스를 쿼리하려면 어떻게해야합니까?

나는 놀 수있는 간단한 공공 서비스를 발견했습니다.

http://www.thomas-bayer.com/sqlrest/CUSTOMER/-151612345/

반환

<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> 

내가 쿼리를 사용하는 경우

:

select * 
from xml 
where url='http://www.thomas-bayer.com/sqlrest/CUSTOMER/-151612345/' 

나는이 XML을 반환받을. 그러나, 나는 어떤 결과가 반환되지 않습니다

select * 
from xml 
where url='http://www.thomas-bayer.com/sqlrest/CUSTOMER/-151612345/' 
    and xpath='//LASTNAME' 

: 예컨대, 하나의 요소로 데이터를 제한하려고합니다.

내가 뭘 잘못하고 있니?

Click here to display the YQL console with the query loaded.

답변

0

당신이 원하는 결과를 필터링에 대한 올바른 키 대신이 itemPath입니다 xpath 없습니다.

SELECT * 
FROM xml 
WHERE url='http://www.thomas-bayer.com/sqlrest/CUSTOMER/-151612345/' 
    AND itemPath='//LASTNAME' 

(Try this query in the YQL console)

쿼리 desc <tablename>을 실행하여 주어진 테이블에 대한 키를 볼 수 있습니다.

desc xml 

(Try this query in the YQL console)를 xml 테이블의 경우

itemPath는 XPath 표현 될 수있는 하나 또는 E4X 경로 점선.

관련 문제