Getting the first line of xml file using QDom
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.
I think we should have a method to get also that tag of xml files :-?
@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.
@p3c0 Thank you. I've been working with QXmlStreamReade. I can read the tag I mentioned in my first message using those methods :)
@tarod.net You're Welcome :) Please mark the post as solved.
@p3c0 The same to you ;)