Re: using minidom

"Alexandro Colorado" <[email protected]>
Newsgroups gmane.comp.python.xml
Organization OpenOffice.org
Message-ID <[email protected]>
>> In case minidom is not a requirement, you can use lxml.etree:
>>
>>   >>> import lxml.etree as et
>>   >>> finditems = et.XPath("//tb:toolbaritem[@tb:visible = 'false']",
>>                         {'tb' : "http://openoffice.org/2001/toolbar"})
>>   >>> tree = et.parse("myfile.xml")
>>   >>> for toolbaritem in finditems(tree):
>>   ...     toolbaritem.set(
>>   ...           "{http://openoffice.org/2001/toolbar}visible", "true")
>>
>>
>> http://codespeak.net/lxml/
>
> Ah, BTW, if you need something that runs under an older Python version (I
> assume you want it to run in OOo), here's a solution that also runs with
> ElementTree (which can be installed on Python 1.5 and later). lxml  
> requires at
> least Python 2.3.

Unfortnately I dont have ET on my distribution of python and dont want to
have dependencies to run my script.

>    >>> import elementtree.ElementTree as et
>    >>> TBNS = "{http://openoffice.org/2001/toolbar}"
>    >>> tree = et.parse("myfile.xml")
>    >>> for tbitem in tree.getiterator(TBNS+"toolbaritem"):
>    ...     if tbitem.get(TBNS+"visible") == "false":
>    ...         tbitem.set(TBNS+"visible", "true")
>
>
> Have fun,
> Stefan



-- 
Alexandro Colorado
OpenOffice.org
Community Contact // Mexico
http://www.openoffice.org

Twitter: http://www.twitter.com/jza
Jabber: [email protected]
_______________________________________________
XML-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/xml-sig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.