xquery: How to load HTML string?
lazarus / 38-Networking and Web Programming
----------------------------------------------------------------------
JR2Media · 2021-05-18 05:23
Is it possible to load a HTML string using xquery in benibela's
InternetTools? I can't find anything in the documentation, or online.
I've tried the following:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
xqvalue(Response.DataString).map('//title').toString;
But this produces an error:
QuoteNeed context item that is a node to get root element
Using debugger I can see that string being passed into xqvalue is
HTML.
----------------------------------------------------------------------
BeniBela · 2021-05-19 18:20
xqvalue only loads a string. It was supposed to be used with an url
like
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
xqvalue(url).retrieve().map('//title').toString
To convert the string to a document, the html parser needs to be
called. There is a function x:parse-html for that. And it cannot be
called in map.
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
xqvalue(Response.DataString).query('x:parse-html($_)//title').toString
There is the legacy function process in simpleinternet, which guesses
if the string is an url or xml or json. But it might be confusing to
debug if it guesses wrong
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
process(Response.DataString, '//title').toString