Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to parse HTML with C++/Qt?

How can i parse the following HTML

<body>
<span style="font-size:11px">12345</span>
<a>Hello<a>
</body>

I would like to retrive the data "12345" from a "span" with style="font-size:11px" from www.testtest.com, but I only want the that very data, and nothing else.

How can I accomplish this?

like image 927
NPLS Avatar asked Sep 07 '13 19:09

NPLS


1 Answers

I think QXmlQuery is what you want. I think the code will be like

QXmlQuery query;

query.setQuery(html, QUrl("/body/span[@style='font-size:11p']"));

QString r;
query.evaluateTo(&r);

You can also provide URL directly to the query

query.setQuery(QUrl("http://WWW.testtest.com"), QUrl("/body/span[@style='font-size:11p']"));
like image 170
Lol4t0 Avatar answered Sep 22 '22 00:09

Lol4t0