On Sat, Apr 24, 2010 at 09:58:19PM +0000, Chris Morley wrote:
> That sounds fine to me. But it's all new to me.
> I will have to study how pncconf parses glade xml to learn how to add
> this ability.
I think it's entirely hidden from the programmer how glade parses its
xml file.
In Python today I think one of the better ways to get data out of an xml
file is using the now-standard "elementtree" module.
>>> import xml.etree.ElementTree
>>> import xml.etree.ElementPath
>>> doc = xml.etree.ElementTree.parse("fw/5i20/SV12.xml")
>>> pin0 = doc.findall("//pins")[0]
>>> pin0.find("secondaryfunctionname").text
'Phase B (in)'
Personally I'd probably encapsulate the xml reading in one location and
have a Python class for the card (corresponding to the whole xml file)
and a class for a pin (corresponding to one "pin" element in the xml
file). That way the reading is separate from the using, which can then
have normal Python syntax like card.pins[0].secondaryfunctionname.
Jeff
------------------------------------------------------------------------------
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers