I am using QGIS 2.4, Python 2.7.5, win 8.1.
I am trying to read layers from QGIS project. When I try define QgsVectorLayer using QDomNode and readXML function, following error appears:
layer.readXML(layerDOM)
AttributeError: 'QgsVectorLayer' object has no attribute 'readXML'
code is here:
from qgis.core import *
from qgis.gui import *
from PyQt4.QtCore import *
from PyQt4.QtGui import QApplication
from PyQt4.QtXml import *
app = QgsApplication([], True)
print app.initQgis()
doc = QDomDocument()
doc.setContent(QFile("composer.qgs"), False)
layers = doc.elementsByTagName("maplayer")
for x in xrange(layers.count()):
layerDOM = layers.at(x)
layer = QgsVectorLayer()
layer.readXML(layerDOM)
app.exitQgis()
Does anybody know, why does the error appear?