Qtreeview中的大Xml

Qtreeview中的大Xml

问题描述:

我有一个很大的XML文件(2000-3000行),我想要通过。目的是显示Qtreeview中的所有数据并突出显示那些可能错误的数据。我已经测试过Qt示例(XBEL)和Jasmin Blanchette书中的示例,但它并没有帮助我作为示例(除了我知道XMLStream不再受支持)。Qtreeview中的大Xml

什么是解析和显示在Qtreeview中突出显示的一些数据的最佳方式是什么? (QTreeView则仅仅是在我的例子中数据的解释,我知道如何处理它)

文件的摘录解析:

<Description xmlns="file://DeviceDescription-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.software.com/schemas/Description-1.0.xsd Description-1.0.xsd file://Description-1.0.xsd OEMcCustom.xsd " xmlns:se="file://Description-1.0.xsd"> 
    <Connector connectorId="1" explicit="false" hostpath="-1" interface="Serial" moduleType="91" role="child" alwaysmapping="true"> 
     <Parameter ParameterId="8000" type="std:BOOL"> 
      <Attributes download="false" offlineaccess="read" /> 
      <Default>true</Default> 
      <Name>NameConfig</Name> 
      <Description>Use the new NameConfig format</Description> 
     </Parameter> 
     <Parameter ParameterId="12345692" type="localTypes:CHANNEL_PACKED"> 
        <Attributes /> 
        <Default> 
         <Element name="FunctionCode">3</Element> 
         <Element name="ReadOffset">16#0000</Element> 
         <Element name="ReadLength">4</Element> 
         <Element name="WriteOffset">0</Element> 
         <Element name="WriteLength">0</Element> 
         <Element name="Trigger">5</Element> 
         <Element name="CycleTime">100</Element> 
         <Element name="ErrorHandling">true</Element> 
         <Element name="EnableRegisterBitMapping" /> 
        </Default> 
        <Name>Channel 1</Name> 
        <Description>ChannelConfig</Description> 
       </Parameter>  
    </Connector> 
</Description> 

http://qt-project.org/doc/qt-5.1/qtxml/qtxml-module.html

注意朝向说明页面底部:

该模块不再被主动维护。相反,请使用Qt Core中的 QXmlStreamReaderQXmlStreamWriter类。

http://qt-project.org/doc/qt-5.1/qtcore/qxmlstreamreader.html#details

这需要一段时间来弄清楚这一个,并用它,但它应该是最快的。获得所有数据验证和错误检查可能会有点痛苦,但是可行。

它添加到一个TreeView可能需要一些更多的思考......但这里有一些指点:

http://qt-project.org/doc/qt-5.1/qtwidgets/qtreeview.html#details

http://qt-project.org/doc/qt-4.8/itemviews-simpledommodel.html

http://qt-project.org/doc/qt-4.8/examples-xml.html

如果仍然是不够的链接,这里有一些更多:

http://qt-project.org/doc/qt-4.8/qsimplexmlnodemodel.html#details

http://qt-project.org/doc/qt-4.8/xmlpatterns-filetree.html

希望有帮助。

+0

这些都是很好的指针,特别是最后2.我改进了这个问题,因为我需要比QTreeview更多的XML数据解释代码。主要的困难是要解释这些示例,以便能够遍历我的xml示例以检索每个标记。谢谢。 – dlewin