You need to write a simple browser core. Accordingly, you need to somehow parse the HTML and create a DOM tree, which will then be transferred to the render.
Googled a lot, but did not find anything concrete and adequate. The problem is that all the information is either very superficial, or found ready written parsers, which I simply could not understand (+ my knowledge of html is very weak, and there is no time to study it).
To begin with, you need to write at least a parser (with hands from scratch, without using ready-made libraries for this). Googled only ideas and primitive algorithms. That is, I imagine how it works, but this is too little to write something.
I would be very grateful if you tell us step by step what to undertake and what to read (if with examples of good articles (very desirable in Russian), then it’s generally chic)
PS In the end, this should be written in Qt, the knowledge of which I also have + is zero, but, as far as I understand, it is practically not required to use it in writing a parser. However, if you tell us which modules will be useful in this, I will be very happy
Closed due to the fact that the issue is too general for the participants user207618, pavel , HamSter , Kirill Stoianov , αλεχολυτ Oct 8 '16 at 12:02 .
Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .
- eightSorry, but how are you going to write a parser of a language that you don’t know, on a framework that you don’t know? - Alexey Ukolov
- oneWell, at least your program should have a lexical analyzer that will understand html and you need to clarify what version of html? Well, as written above, without the knowledge of one and understanding how the other works, it is not possible. - Alex.B
- take a look at this question. stackoverflow.com/questions/120273/… - Alex.B
- @ AlekseyUkolov, minus minus give plus, it means knowledge :) And the question is stupid in this form. - user207618
|
1 answer
In the simplest version, you can use QDomDocument ( Documentation ).
Example:
QByteArray data; ... QDomDocument doc; if (doc.setContent(data, false, &errorMsg, &errorLine, &errorColumn)) { QDomElement root = doc.documentElement(); QDomNode node = root.firstChild(); while (!node.isNull()) { QDomElement el = node.toElement(); if (!el.isNull()) { qDebug() << qPrintable(el.tagName()); } node = node.nextSibling(); } } else { qDebug() << QString("Error in line %1, column %2: %3").arg(errorLine).arg(errorColumn).arg(errorMsg); } |