How to return "NA" for no result returned from YQL
I am using YQL to parse multiple fields from HTML file. My YQL looks like:
Select content from html where url="http://somedomain/somepage.html" and xpath='//field1 | //field2 | //field3'
The query works fine but not all fields have values a开发者_如何学编程ll the time. I would like the YQL to return me NULL or NA for fields that are not available. At the moment the query doesnt return me anything for fields that are not available. For example if field2 was not present in HTML page I would get XML formatted result:
< result >
< field > val1 < /field>
< field > val3 < /field>
< /result >
What I would like it to return is:
< result >
< field > val1 < /field>
< field > NA < /field >
< field > val3 < /field>
< /result >
Appreciate any help I can get.
Thanks
I think you will not get away with an as easy YQL query as you are describing. Most probably you have to put the response together yourself and put everything in the <execute>
block of your own YQL table.
Instead of this: Why not check after your receive the results from YQL, if you got a value for //field2
or not?
精彩评论