Hi,

             I have to parse an xml file, get to a spefic node, and
set it to a different value and write it back to the file. What is the
best way to do it ? The xml file can be a few hundred lines(with
proper formatting).

For parsing, I use lxml with xpath. I am doing something like this.

from lxml import etree

<---Open the XML file etc.--->
p_data = etree.parse(xml_data)

I use xpath like
p.xpath(/foo/bar[@id=xyz])

But I don't really know how to update an entry and write it back to
the xml file ? Can someone suggest some ways please ? Also, it is
necessary that it should be XPath based. Thanks

-- 
Thank you
Balachandran Sivakumar

Arise Awake and stop not till the goal is reached.
                                                             - Swami Vivekananda

Mail: benignb...@gmail.com
Blog: http://benignbala.wordpress.com/
_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to