QDomDocument doesn't accept parentheses when parsing an xml file
When there is a parenthesis contained in a node of xml file the QDomDocument::setContent gives error "error occurred while parsing element". The error column is right where the parenthesis is. Remove all parentheses and there is no error.
Codes:
Code:
doc.setContent(&file);
file.close();
xml file:
Code:
<root>
<node(>
</node(>
</root>
I have googled but found no restriction to parentheses usage in xml file. And I can save nodes with parentheses successfully, with QDomDocument::save. How can I retrieve it?
Re: QDomDocument doesn't accept parentheses when parsing an xml file
QDomDocument is telling you that the input is malformed because parentheses are not permitted in an XML element Name: http://www.w3.org/TR/REC-xml/#sec-starttags
Re: QDomDocument doesn't accept parentheses when parsing an xml file
Well it looks like my manual does not mention that. And it's strange that the QDomDocument allows it when saving the doc to xml files.
So what should I do if the users insist putting parentheses in the element names?
Re: QDomDocument doesn't accept parentheses when parsing an xml file
Convert them to another set of characters before passing the data to QDomDocument.
Re: QDomDocument doesn't accept parentheses when parsing an xml file
Or train your users to correctly specify XML element names. Refuse to permit anything except allowed characters in XML strings and put up an error dialog if the user types a character that isn't allowed by the standard.