Well... your file is not xml, it's "xml-like". Every proper xml parser should bail out on this. What you could do is that you can prescan the whole file using a regular expression and convert all invalid attributes to valid ones before passing the text to an xml parser. Something like:
QMap<QString,QString> replacements;
replacements.insert("<", "<");
replacements.insert(">", ">");
// etc
QMapIterator<QString,QString> iter(replacements);
while(iter.next()){
text = text.replace(iter.key(), iter.value());
}
QMap<QString,QString> replacements;
replacements.insert("<", "<");
replacements.insert(">", ">");
// etc
QMapIterator<QString,QString> iter(replacements);
while(iter.next()){
text = text.replace(iter.key(), iter.value());
}
To copy to clipboard, switch view to plain text mode
Of course this is an oversimplification as this would replace all angle brackets and that's certainly not what you want. You have to detect attributes first (using regular expressions) and only operate on their contents.
Maybe something like this?
QRegExp("([A-Za-z]+)\\s*=\\s*\"([^\"]+)\"");
// cap(1) contains attr name, cap(2) contains value
QRegExp("([A-Za-z]+)\\s*=\\s*\"([^\"]+)\""); // cap(1) contains attr name, cap(2) contains value
To copy to clipboard, switch view to plain text mode
Bookmarks