how to use QXmlStreamWriter ::writeCurrentToken
-
wrote on 4 Jul 2023, 10:02 last edited by
when i read xml by QXmlStreamReader,and write by QXmlStreamWriter ::writeCurrentToken to a new file, the new file add "n1:" in each element,why?
my code is like this
QXmlStreamWriter *m_pWriter = new QXmlStreamWriter(&fileNew);
m_pWriter->setAutoFormatting(true);
m_pWriter->setCodec("ISO-8859-1");
//
while (!m_pReader->atEnd() && !m_pReader->hasError())
{m_pReader->readNext(); m_pWriter->writeCurrentToken(*m_pReader); }
-
You don't say anything about the input XML, but this sounds like https://bugreports.qt.io/browse/QTBUG-75456 .
-
You don't say anything about the input XML, but this sounds like https://bugreports.qt.io/browse/QTBUG-75456 .
-
@kkoehne
Just so I understand: that bug is "critical" but "unresolved" from 2019, and the comments indicate it's not going to be solved?@JonB Yeah, something went wrong here. Will follow up.
-
You don't say anything about the input XML, but this sounds like https://bugreports.qt.io/browse/QTBUG-75456 .
-
@Owen_cn said in how to use QXmlStreamWriter ::writeCurrentToken:
the input xml start element is like <tagXXX>
and int the new file the start element is n1:tagXXXBut is tagXXX in a 'default' namespace? That is, does your input XML have a "xmlns" attribute?
If you have a minimal XML, we could see whether it is indeed QTBUG-75456, or something else.
-
wrote on 5 Jul 2023, 07:46 last edited by
@Owen_cn said in how to use QXmlStreamWriter ::writeCurrentToken:
the input xml start element is like <tagXXX>
and int the new file the start element is n1:tagXXXIs this not exactly what that bug report describes?
-
wrote on 6 Jul 2023, 01:41 last edited by
for example the source xml file
//
<?xml version="1.0" encoding="ISO-8859-1"?>
<indexedmzML xmlns="http://psi.hupo.org/ms/mzml">
<mzML xmlns="http://psi.hupo.org/ms/mzml">
</mzML>
</indexedmzML>use writeCurrentToken to write a new file, the output is like this
<?xml version="1.0" encoding="ISO-8859-1"?>
<n1:indexedmzML xmlns="http://psi.hupo.org/ms/mzml">
<n1:mzML xmlns="http://psi.hupo.org/ms/mzml">
n1:/mzML
n1:/indexedmzML
1/8