<div dir="ltr"><br><br>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 :<br><br>class testparseDialog(QtGui.QDialog):<br>
def __init__(self):<br> QtGui.QDialog.__init__(self)<br> # Set up the user interface from Designer.<br> self.ui = Ui_testparse()<br> self.ui.setupUi(self)<br><br> opendata = self.ui.btnCari<br>
QtCore.QObject.connect(opendata, QtCore.SIGNAL('clicked()'),self.openxml)<br><br> def openxml(self, event=None):<br><br> #open dialog<br> openfile = QtGui.QFileDialog.getOpenFileName(self, 'Open File', '*.xml')<br>
<br> self.ui.lineLokasi.setText(openfile)<br><br> #call XML data<br> self.isiData(openfile)<br><br> def isiData(self, nmsatu):<br> #open teks with read mode<br> openteks = open(nmsatu, 'r').read()<br>
<br> self.ui.textXml.setText(openteks)<br><br>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<br>
<br>can someone tell me how to convert xml into variable?<br><br>and Xml i try to parse have format like this<br><br><gmd:dateStamp><br> <gco:Date>2013-12-12</gco:Date><br><br>Thanks for Advance <br>
<br></div>