Re: using minidom

"Alexandro Colorado" <[email protected]>
Newsgroups gmane.comp.python.xml
Organization OpenOffice.org
Message-ID <[email protected]>
On Mon, 25 Jun 2007 07:15:14 -0500, Stefan Behnel <[email protected]>
wrote:

> Hi,
>
> Alexandro Colorado wrote:
>> So basically this is what I want, I want to progamatically be able to
>> change the atribute of an XML:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE toolbar:toolbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument
>> 1.0//EN" "toolbar.dtd">
>> <toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar"
>> xmlns:xlink="http://www.w3.org/1999/xlink">
>>   <toolbar:toolbaritem xlink:href=".uno:OpenUrl"  
>> toolbar:visible="false"/>
>> ....
>> </toolbar:toolbar>
>>
>> I want to change the toolbar:visible atribute from false to true
>> preffering to use minidom.
>
> In case minidom is not a requirement, you can use lxml.etree:

only minidom/dom or  sax

>   >>> 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/
>
> 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.