Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>YQL requires the xpath expression to evaluate to an itemPath rather than node text. But once you have an itemPath you can project various values from the tree </p> <p>In other words an ItemPath should point to the Node in the resulting HTML rather than text content/attributes. YQL returns all matching nodes and their children when you select * from the data.</p> <p>example </p> <pre><code>select * from html where url="http://stackoverflow.com" and xpath='//div/h3/a' </code></pre> <p>This returns all the a's matching the xpath. Now to project the text content you can project it out using </p> <pre><code>select content from html where url="http://stackoverflow.com" and xpath='//div/h3/a' </code></pre> <p>"content" returns the text content held within the node. </p> <p>For projecting out attributes, you can specify it relative to the xpath expression. In this case, since you need the href which is relative to a.</p> <pre><code>select href from html where url="http://stackoverflow.com" and xpath='//div/h3/a' </code></pre> <p>this returns <code>&lt;results&gt; &lt;a href="/questions/663973/putting-a-background-pictures-with-leds"/&gt; &lt;a href="/questions/663013/advantages-and-disadvantages-of-popular-high-level-languages"/&gt; .... &lt;/results&gt; </code></p> <p>If you needed both the attribute 'href' and the textContent, then you can execute the following YQL query: </p> <pre><code>select href, content from html where url="http://stackoverflow.com" and xpath='//div/h3/a' </code></pre> <p>returns:</p> <pre><code>&lt;results&gt; &lt;a href="/questions/663950/double-pointer-const-issue-issue"&gt;double pointer const issue issue&lt;/a&gt;... &lt;/results&gt; </code></pre> <p>Hope that helps. let me know if you have more questions on YQL.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload