[Qgis-user] convert xml into variable with type of list/dictionary

Suryo Miles suryomiles666 at gmail.com
Sun Apr 20 21:46:27 PDT 2014


Hay i m new in python and i have a task to make plugin in QGIS and use this
code to open xml file and then read it in QTextBrowser, this is code i use
to open xml file :

class testparseDialog(QtGui.QDialog)
:
    def __init__(self):
        QtGui.QDialog.__init__(self)
        # Set up the user interface from Designer.
        self.ui = Ui_testparse()
        self.ui.setupUi(self)

        opendata = self.ui.btnCari
        QtCore.QObject.connect(opendata,
QtCore.SIGNAL('clicked()'),self.openxml)

    def openxml(self, event=None):

        #open dialog
        openfile = QtGui.QFileDialog.getOpenFileName(self, 'Open File',
'*.xml')

        self.ui.lineLokasi.setText(openfile)

        #call XML data
        self.isiData(openfile)

    def isiData(self, nmsatu):
        #open teks with read mode
        openteks = open(nmsatu, 'r').read()

        self.ui.textXml.setText(openteks)

but then when i try to parse xml i open with code above i read it must be
converted into a variable with the type of "list/dictionary" and only after
that it can be parsed with ElementTree or other parse method

can someone tell me how to convert xml into variable?

and Xml i try to parse have format like this

<gmd:dateStamp>
      <gco:Date>2013-12-12</gco:Date>

Thanks for Advance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20140421/8b919fe8/attachment.html>


More information about the Qgis-user mailing list