I try to get text content inside execute script of open table…
My query is like :
var q = y.query('select * from html where url="http://awebpage.html" and xpath="/html/body/div/table/tr/td/table/tr/td/div/div[2]/center/div[3]//text()"');
y.log(q.results);
This work fine and i can see in log of console the text of the content. But i don’t know how i can return this!!
if i try
response.object = {'test': q.results } };
don’t work…. i try to write :
response.object = {'test': q.results.toXMLString() } };
but it return something like : { 'test' : '<result> bla bla bla bla </result>' }
How can i get only the content of result?!?! I need only “bla bla bla”
As it looks like you know,
q.resultsis an XML object. To get the text content as a string you would first calltext()to get an XML text object, then calltoString()to turn it into a JavaScript string.There is also the option of simply returning an XML object of your own.