0

Here's the scenario, I use QtNetwork module to retrieve a html page from internet,

In the old days, I just create a new QWebPage object, and use the setHtml() function to load it, and parse it (find specific tags and attributes), but that looked lame.

Now I think I could do it through QtScript, I would give a QByteArray as input, and parse the page, get some elements and attributes, but with javascript syntax.

i.e in the old days I do QWebElement::findFirst() plus a foreach loop over them, now I want to do getElementByID like stuff, not with C++ code, but pure js.

That's possible? If so, can anyone give an example of code? I'm running Qt 4.8.4

Or whatever that can avoid the QWebElement style parsing.

daisy
  • 22,498
  • 29
  • 129
  • 265

1 Answers1

0

QTScript is a based on ECMAScript with some extension like signal/slots. It does not implements DOM.

QTScript has actually implemented ECMA-262 3rd Edition. So it is not possible to use getElementByID in QTScript because it's not defined in the ECMAScript standard as it is actually defined in DOM.

However, you can create your own wrapper functions for DOM manipulation or you can also use the QWebElement.findFirst() method from QTScript.

Aamir Abro
  • 838
  • 12
  • 24