Why can't I parse a XML file using QXmlStreamReader from Qt?

后端 未结 5 1775
长发绾君心
长发绾君心 2021-02-14 06:43

I\'m trying to figure out how QXmlStreamReader works for a C++ application I\'m writing. The XML file I want to parse is a large dictionary with a convoluted structure and plent

5条回答
  •  渐次进展
    2021-02-14 06:56

    About the encoding: As baysmith and and hmuelner said, your file is probably incorrectly encoded (unless the encoding got lost when pasting it here). Try to fix that with some advanced text editor.

    The problem with your usage of text() is that it doesn't work as you expect it to. text() returns the content of the current token if it is of type Characters, Comment, DTD or EntityReference. Your current token is a StartElement, so it's empty. If you want to consume/read the text of the current startElement, use readElementText() instead.

提交回复
热议问题