0
votes

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"

1

1 Answers

0
votes

As it looks like you know, q.results is an XML object. To get the text content as a string you would first call text() to get an XML text object, then call toString() to turn it into a JavaScript string.

response.object = {'test': q.results.text().toString()};

There is also the option of simply returning an XML object of your own.

response.object = <test>{q.results.text()}</test>;