PDA

View Full Version : QDomDocument & XML



ManuMies
29th April 2009, 07:27
I'm trying to use QDomDocument to parse xml file, but QDomDocument puts all the xml comments also in elements. Is there way to read the xml and ignore the comments? Nnow the whole idea about having comments is pretty much useless as they act as any other elements... :(

Lykurg
29th April 2009, 07:46
I'm happy Qt does so, because if not you cannot modify your file without loosing the comments. And maybe you want modify them manually. But how you can remove the comments:

Loop throught the nodes and delete all QDomNode::CommentNode nods
Load your file and remove all comments with a reg exp before setting the file to your dom document