0

xpath vs. itemPath

When selecting data tables from html there is a great way to filter out DOM elements using xpath. What are my options to do similar things when selecting from json? I saw you can specify an itemPath, but how can I accomplish something like this?
CODE
select * from html where url="http://www.example.com" and
xpath='//p[2]'

So, taking just a specified element of an array in a JSON object.

Thanks
-Martin

by
2 Replies
  • QUOTE (martinmpm85 @ Apr 11 2010, 02:18 AM) <{POST_SNAPBACK}>
    When selecting data tables from html there is a great way to filter out DOM elements using xpath. What are my options to do similar things when selecting from json? I saw you can specify an itemPath, but how can I accomplish something like this?
    CODE
    select * from html where url="http://www.example.com" and
    xpath='//p[2]'

    So, taking just a specified element of an array in a JSON object.

    Thanks
    -Martin


    Im not sure what you're trying to do. You can limit the number of items being fetched into YQL from any table using the parens:

    select * from table(10)

    ... and you can limit the number of items once YQL has finished applying any local filtering you'd like:

    select * from table where something LIMIT 10

    You can filter out parts of the repeating elements using local filters in the where clause:

    select * from table where item.path.element.name like "%foo%"

    In general the xpath is really only used in the HTML table to break it down into the rows that YQL will return. Everything else is item path based. You can also use xpath in an open data table "execute" javascript too.

    Jonathan
    0
  • Thank you Jonathan. I'm gonna see what works for me.
    0

Recent Posts

in YQL