في برنامج برق لدي ملف xml يخزن حالة التحميلات الحالية
<?xml version="1.0" encoding="UTF-8"?>
<Download Gid="1">
<fileName>oneiric-desktop-amd64.iso</fileName>
<Url>http://cdimage.ubuntu.com/releases/oneiric/alpha-3/oneiric-desktop-amd64.iso</Url>
<Status>active</Status>
<Size>743.75 Mb</Size>
</Download>
<Download Gid="2">
<fileName>pmagic-6.1.iso</fileName>
<Url>http://downloads.sourceforge.net/partedmagic/pmagic-6.1.iso</Url>
<Status>active</Status>
<Size>170.92 Mb</Size>
</Download>
<Download Gid="3">
<fileName>salix64-xfce-13.37.iso</fileName>
<Url>http://downloads.sourceforge.net/salix/salix64-xfce-13.37.iso</Url>
<Status>active</Status>
<Size>608.16 Mb</Size>
</Download>أستخدم هذه الدالة لقراءة الملف
def offlineData(self): #Fille Gui from saved data when no internet connection
#Read Data from Status.xml
xmlFile = QtCore.QFile(homeDir+"/.Barq/Status.xml")
xmlFile.open(QtCore.QFile.ReadOnly)
reader = QtCore.QXmlStreamReader(xmlFile)
i=0
while not (reader.atEnd() & reader.hasError()):
reader.readNext()
if reader.name().toString() == "Download":
gid = reader.attributes().value("Gid")
print str(gid)
if reader.isStartElement():
if reader.name().toString() == "fileName":
fileName = str(reader.readElementText())
print fileName
if reader.name().toString() == "Url":
url = str(reader.readElementText())
print url
if reader.name().toString() == "Status":
status = str(reader.readElementText())
print status
if reader.name().toString() == "Size":
size = str(reader.readElementText())
print sizeناتج تنفيذ هذه الدالة ليس كما اتوقع فهو كالتالي
1 oneiric-desktop-amd64.iso http://cdimage.ubuntu.com/releases/oneiric/alpha-3/oneiric-desktop-amd64.iso active 743.75 Mb 2
المفترض أن يكون الناتج كالتالي
1 oneiric-desktop-amd64.iso http://cdimage.ubuntu.com/releases/oneiric/alpha-3/oneiric-desktop-amd64.iso active 743.75 Mb 2 pmagic-6.1.iso http://downloads.sourceforge.net/partedmagic/pmagic-6.1.iso active 170.92 Mb 3 salix64-xfce-13.37.iso http://downloads.sourceforge.net/salix/salix64-xfce-13.37.iso active 608.16 Mb
تري ما الخطأ في الكود ؟؟؟؟
