[Qgis-user] change element into Qstring in ElementTree
Alex Mandel
tech_dev at wildintellect.com
Mon Apr 28 16:10:55 PDT 2014
Please move this conversation over to the qgis-developer mailing list
since it's about writing code.
FYI, there are several examples of how to do this in older plugins. It
might be easier to just fix them to work in QGIS 2+
http://plugins.qgis.org/plugins/metaedit/ ( I wrote this one )
http://plugins.qgis.org/plugins/metatools/
Thanks,
Alex
On 04/28/2014 04:04 PM, Suryo Miles wrote:
> I try to make QGIS plugin to open and show metadata information in xml
> format i use this code to open metadata from drive and show it in UI:
>
> *from PyQt4 import QtCore, QtGuifrom ui_testparse import Ui_testparseimport
> xml.etree.ElementTree as ETree# create the dialog for zoom to pointclass
> 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)#Parse XML from Above
> self.parsenow(openteks) def parsenow(self, parse): element =
> ETree.fromstring(parse) xml_obj = ETree.ElementTree(element)
> for title_obj in
> xml_obj.findall('./{gmd#}dateStamp/{gco#}Date'): print
> element self.ui.lineSkala.setText(element)*But the value i want
> to show didn't appear in QLineEdit (LineSkala), i dont get any error
> message, it just blank, xml i want to parse look like this :
>
>
>
> *<gmd:dateStamp> <gco:Date>2013-12-12</gco:Date> </gmd:dateStamp>*
>
> someone in forum tell me i must change element in print element to a
> QString so QLineEdit can read it and show it, but i didn't know how to do
> it, i really newbie in python
>
> Can someone teach me?
>
>
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>
More information about the Qgis-user
mailing list