[Qgis-user] QGIS Plugin to open and parse xml metadata
Alex Mandel
tech_dev at wildintellect.com
Mon Mar 24 10:55:55 PDT 2014
It may also help to look at the 2 older metadata plugins for how they do
the parsing:
http://plugins.qgis.org/plugins/metaedit/
http://plugins.qgis.org/plugins/metatools/
Thanks,
Alex
On 03/24/2014 10:04 AM, Horst Düster wrote:
> substitute filename with self.filename than it should work
>
>
> All the best
> Horst Düster
>
>
> Am 24.03.2014 17:45, schrieb Suryo Miles:
>> I make plugin in QGIS to open and read XML file, then parse it and show
>> scale map from it, its a big xml file and line with scale information have
>> format like this
>>
>> <gmd:denominator><gco:Integer>ScaleValue</gco:Integer></gmd:denominator>
>>
>> and i try code like this to open xml file and then parse it:
>>
>> from PyQt4 import QtCore, QtGuifrom ui_latih import Ui_latih# create
>> the dialog for zoom to point
>>
>> class latihDialog(QtGui.QDialog):
>> def __init__(self):
>> QtGui.QDialog.__init__(self)
>> # Set up the user interface from Designer.
>> self.ui = Ui_latih()
>> self.ui.setupUi(self)
>>
>> cariButton = self.ui.btnCari
>> QtCore.QObject.connect(cariButton, QtCore.SIGNAL('clicked()'),self.cari)
>>
>> def cari(self, event=None):
>>
>> #open dialog
>> filename = QtGui.QFileDialog.getOpenFileName(self, 'Open File', '*.xml')
>>
>> self.ui.lineFile.setText(filename)
>>
>> #call text
>> self.isiDataFile(filename)
>>
>> def isiDataFile(self, nmfile):
>> #open with read mode
>> teksFile = open(nmfile, 'r').read()
>>
>> self.ui.textFile.setText(teksFile)
>>
>> import xml.etree.ElementTree as ET
>>
>> tree = ET.parse(filename)
>> doc = tree.getroot()
>>
>> for elem in doc.findall('Default_Config/gmd:denominator'):
>> x = elem.tag, elem.text
>> self.ui.lineSkala.setText(x)
>>
>> for elem in doc.findall('Default_Config/gmd:MD_Format'):
>> y = elem.tag, elem.text
>> self.ui.lineFitur.setText(y)
>>
>> I try using Element Tree to parse and show ScaleValue in LineEdit because
>> its integrated in python, but i have error message like this :
>>
>> NameError: name 'filename' is not defined
>>
>> i am really newbie in python and xml parser, can i pass the xml location
>> from open xml code to
>>
>> tree = ET.parse( )
>>
>> because i plan to open more than one xml file and scale in one and another
>> xml file have different value as well
>>
>> Can Someone help me?
>>
>>
>>
>> _______________________________________________
>> Qgis-user mailing list
>> Qgis-user at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-user
>
>
>
> _______________________________________________
> 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