QXmlStreamReader fails when child element is on next line?
-
Hi.
I am usingQXmlStreamReader
to read an XML file<?xml version="1.0" encoding="utf-8"?> <rm> <nm>Name</nm> <if>Info</if> <ff>Format</ff> <ic>Icon</ic> <bt> <it><b>Button1</b><c>code</c><i>icon</i></it> <it> <b>Button2</b> <s> <si><d>Macro1</d><c>code1</c></si> <si><d>Macro2</d><c>code2</c></si> </s> <i>icon</i> </it> ...
The reader fails when it encounters the first
<s>
element, printing only:D libTest: (null):0 ((null)): "s" "\n "
errorString()
prints the following:D libWifi2IR: (null):0 ((null)): "Expected character data."
Once this error occurs, parsing is interrupted and I don't even get the rest of the file.
How can I avoid this behavior? -
Hi @VRonin
I just realized that since I am not further querying for the children inside the<s>
element at this stage (I do it later, in QML), I should either just skip reading the text for that element, or usereadElementText(QXmlStreamReader::IncludeChildElements)
instead of just using:
readElementText()
Somehow, just posting the "problem" helps to clarify things...
Sorry for the disturbance... -
Hi @VRonin
I just realized that since I am not further querying for the children inside the<s>
element at this stage (I do it later, in QML), I should either just skip reading the text for that element, or usereadElementText(QXmlStreamReader::IncludeChildElements)
instead of just using:
readElementText()
Somehow, just posting the "problem" helps to clarify things...
Sorry for the disturbance... -
@VRonin said in QXmlStreamReader fails when child element is on next line?:
Just to be clear, since <s> has no text, the error is the correct behaviour for the parser
Yes, I naively thought that the child elements inside
<s>
would be considered as the 'value' for that<s>
element. Another thing learned today...
As always, thanks for reacting!