[Twisted-Python] regarding xml elements
phil at bubblehouse.org
Fri Mar 28 10:32:44 EDT 2008
On Mar 28, 2008, at 7:44 AM, Raj kumar wrote:
> I have an xml file in my application,
> I have created an element using
> Example goes like this.........
> and i appeneded it by using append() method.
> But how i can reflect this change to my xml file?
> and one more thing is i want to create element with some other
> <abc m=" " n=" ">
> and i have m and n values as strings with me..
> can anybody help me to create this element and write it to the
> existing xml file
> as a child of an existing element?
It sounds like you're working with t.w.microdom. I believe you'll want
to use Document.writexml(). It's not documented in the code, and I
haven't looked anywhere else, but you should be able to use it like
def writexml(self, stream, indent='', addindent='', newl='',
You'll probably want to ignore most of the parameters. I'm fairly sure
indent, addindent,newl, and strip are related to pretty-printing. I've
never used the namespace-related vars either, so I can't really tell
you what they do ;-)...
Also, in case it's not obvious, 'stream' should be a file object of
To add attributes to your element, you can invoke createElement like
Then just append() it normally as you've already done.
More information about the Twisted-Python