Parsing non-well formed XML with Qt
문제
I'd like to use Qt to parse a non-well formed XML document of the form:
<log_data>
//lots of data
</log_data>
<log_data>
//more data
</log_data>
//etc.
Is this even possible or does the Qt XML parsing libraries absolutely require well-formed XML?
Thanks in advance.
해결책
Create a skeleton document wrapper.xml:
<!DOCTYPE wrapper [
<!ENTITY e SYSTEM "real.xml">
]>
<wrapper>&e;</wrapper>
where real.xml is the XML fragment you actually want to read; then point your XML parser at wrapper.xml.
다른 팁
Just add a <root>
before it and a </root>
after it, and you have a valid XML document.
제휴하지 않습니다 StackOverflow