Getting the first line of xml file using QDom
-
Hello there!
I'm trying to parse an xml file using QDomDocument and related classes, but I cannot get the first line of this file.
Usually every xml file has as a first line like the following one:
<?xml version="1.0" encoding="UTF-8"?>
And the problem is I cannot read that line.
Any idea? Is it possible or the first node returned by QDomDocument is always after that header?
-
Disclaimer: Never used QDom.
Normally , an xml paser will return the root object
which is the first node/element in the document AFTER the "header"QDomElement QDomDocument::documentElement() const
Returns the root element of the document. -
@tarod.net I guess there's no way to do so using QDomDocument. Strange that it has adding functionality using createProcessingInstruction but no reading.
You can use QXmlStreamReader instead. It has documentEncoding and documentVersion methods. -
@tarod.net You're Welcome :) Please mark the post as solved.
Happy Coding..