将XML添加到文本框

时间:2011-07-26 08:56:43

标签: python xml pyqt qtextedit

我想在QTextEdit中添加一个xml,这是我的代码

self.XMLField = QtGui.QTextEdit() # Alternative: QTextEdit
self.XMLField.setReadOnly( True )            
self.XMLField.setAcceptRichText( True )
self.XMLField.append( data.toxml() )
print( data.toxml() )  

打印正在运行,因此我获得了整个XML,但在文本框中我只获得了nodeValues和属性。

ADDED 这是完整的代码:

        path = "settings/%s.xml" % str( self.clientName )
        print( path );
        data = xml.dom.minidom.parse( path )       
        lidar = data.getElementsByTagName( 'lidar' )
        if( lidar.length > 0 ):
            positive_towards_LOS = lidar[0].getAttribute( 'positive_towards_LOS' )        
            scanner_3D = lidar[0].getAttribute( 'scanner_3D' )            
            name = ( lidar[0].getElementsByTagName( 'name' ) )
            if( name.length > 0 ):
                title = 'Windscanner - %s Lidar Properties' % name[0].firstChild.nodeValue
                self.setWindowTitle( title )

            """    XML Showup    """
            self.XMLField = QtGui.QTextEdit() # Alternative: QTextEdit
            self.XMLField.setReadOnly( True )            
            self.XMLField.setAcceptRichText( True )
            self.XMLField.append( data.toxml() )  

0 个答案:

没有答案