[PyQt] Kind of newbie question about reading XML file

Gustavo A. Díaz gustavo.diaz at gmail.com
Thu Dec 11 15:07:53 GMT 2008


Hi Again, Anyone any tip about his?

Thanks.

Cheers.


--
GuS

2008/12/5 Gustavo A. Díaz <gustavo.diaz at gmail.com>

> Hi,
>
> Maybe in a future, but I use this XML in many places on my app... and i
> dont have right now time for changing the code... Since i write and i read
> that file.
>
> Thanks anyway...
>
> 2008/12/5 Detlev Offenbach <detlev at die-offenbachs.de>
>
> Hi,
>>
>> why not use the SAX based interface? I find the SAX approach easier to
>> understand and to implement.
>>
>> Regards,
>> Detlev
>>
>> On Freitag, 5. Dezember 2008, Gustavo A. Díaz wrote:
>> > Hi guys,
>> >
>> > I am facing a problem when how to read a XML with tags, and sub tags.
>> Like
>> > for example:
>> >
>> > <FirstTag>
>> >     <SecondTag>
>> >         <data1>text</data1>
>> >         <data2<text</data2>
>> >     </SecondTag>
>> > <FristTag>
>> >
>> > The thing is that before I was  using just one tag like:
>> >
>> > <FirstTag>
>> >     <data1>text</data1>
>> >     <data2<text</data2>
>> > <FristTag>
>> >
>> > and I've found examples (of course in Qt docs) of how to achieve the
>> > reading of this example of XML. But now i don't know how. And most cause
>> i
>> > am still newbie, and more working with XML files.
>> >
>> > So, my old code is:
>> >
>> > self.file = QFile(PREFERENCES_FILE)
>> > self.file.open(QIODevice.ReadOnly)
>> > self.doc = QDomDocument("OpenCoffee")
>> > self.doc.setContent(self.file)
>> > self.file.close()
>> >
>> > self.docElem = self.doc.documentElement()
>> >         self.node = self.docElem.firstChild()
>> >
>> >         while (self.node.isNull() == False):
>> >             self.element = self.node.toElement()
>> >
>> >             if (self.element.isNull() == False):
>> >                 if (self.element.tagName().contains("systemTray")):....
>> etc
>> > etc.
>> >
>> > But of course this will not work now, since i have to read trwo 2 tags
>> > before searching the elements inside them.
>> > Can someone give my a hand on this? i've droped this part of the code in
>> my
>> > app since i dont find any usefull clear example of how to do it.
>> >
>> > Ataching my XML file.
>> >
>> > Thanks a Lot.
>>
>>
>>
>> --
>> Detlev Offenbach
>> detlev at die-offenbachs.de
>>
>
>
>
> --
> Gustavo A. Díaz
> GDNet Projects
> www.gdnet.com.ar
>



-- 
Gustavo A. Díaz
GDNet Projects
www.gdnet.com.ar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20081211/6d2ae067/attachment.html


More information about the PyQt mailing list