Hi there,
I have put together some YQL code that works for RSS feeds, but I'm trying to get it to parse some HTML for me. I'm wondering what's wrong here:
This code works fine:
function buildListOfItems(data) {
var items = data.query.results.item;
var output = '';
if (items && item.length) {
var no_items=items.length;
for(var i=0;i<no_items;i++){
var title = items[i].title;
var content = items[i].content;
output += title + "-->" + content + "<br/>";
}
return output;
}else{
alert('no data returned!');
}
}
function theCallback(data) {
$("#menuitems").html(buildListOfItems(data));
}
$.YQL = function(query, callback){
$.ajax({
type: "GET",
url: 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(query.toLowerCase()) + '&format=json&diagnostics=false&callback=?',
success: callback,
dataType: "jsonp"
});
};
$(document).ready(function() {
$.YQL("select * from feed where url='http://feeds.feedburner.com/t3kd?format=xml' limit 10", theCallback);
});
but if I change the YQL line to something like this:
$.YQL('select title,content from html where url="http://www.mywebsite.com/index.php?page=10" and xpath='//h3/a''', theCallback);
then I get 'no data returned'
However the query works fine in the YQL console, I wonder am I just not encoding the string right or missing a single quote vs double quote problem?
If anybody can help me I'd really appreciate it.
Thanks