I try to parse XML file which contains a attribute tag like this:
a="(USA & CANADA)"
But i found out that it isn’t well-formed XML because the”&” should be URL-encoded (&)
Is there a way to tell QDom to ignore the invalid text to parse the file anyway? Because i can’t just fix all XML-files.
I’d greatly appreciate any solutions to this problem.
EDIT: I figured out that there is a function setInvalidDataPolicy(AcceptInvalidChars) but either this doesn’t work when using setContent() for the QDomDocument or I’m just using it the wrong way…
QDomDocument xmlcontent;
QDomImplementation impl;
impl.setInvalidDataPolicy(QDomImplementation::AcceptInvalidChars);
QFile XMLContentFile(pathString);
xmlcontent.setContent(&XMLContentFile)
Anyone any ideas? Thanks in advance!
I worked my way around the problem.
I now parse the XML file using QXmlStreamReader and when it raises an error I start a own function to fix the XML file. Then a restart my parse routine.
This does the job and I couldn’t find a better way to achieve this.