get textual content of a Xml element using 4DOM

and-google at and-google at
Sun Mar 6 09:21:16 CET 2005

Frank Abel Cancio Bello <FRANKA... at> wrote:

> PrettyPrint or Print return the value to the console, and i need
> keep this  value in a string variable to work with it, how can i
> do this?

The second parameter to either of these functions can be a stream
object, so you can use a StringIO to get string output:

  from StringIO import StringIO
  from xml.dom.ext import Print

  buf= StringIO()
  Print(doc, buf)
  xml= buf.getvalue()

Andrew Clover
mailto:and at

More information about the Python-list mailing list