Hello Jerry,
Tricky solution using minidom (standard) Not tested:
import ElementTree
import minidom
def prettyPrint(element):
txt = ElementTree.tostring(element)
print minidom.parseString(txt).toprettyxml()
Regards
Karim
On 08/22/2010 04:51 PM, Jerry Hill wrote:
On Fri, Aug 20, 2010
Jerry Hill, 22.08.2010 16:51:
Neither, as far as I know. The XML you get is perfectly valid XML.
It's clearly well-formed, but I can't see it being valid without some kind
of schema to validate it against.
Note that the OP has already written a follow-up but forgot to reply to the
origin
Sorry wrong import!
from xml.minidom import parseString
from xml.etree import ElementTree
Karim
On 08/22/2010 05:24 PM, Karim wrote:
Hello Jerry,
Tricky solution using minidom (standard) Not tested:
import ElementTree
import minidom
def prettyPrint(element):
txt = ElementTree.tostring(
On Fri, Aug 20, 2010 at 3:49 AM, Knacktus wrote:
> Hi guys,
>
> I'm using Python 2.7 and the ElementTree standard-lib to write some xml.
>
> My output xml has no line breaks! So, it looks like that:
>
>
>
> instead of something like this:
>
>
>
>
>
> I'm aware of lxml which seems to have a
Hi guys,
I'm using Python 2.7 and the ElementTree standard-lib to write some xml.
My output xml has no line breaks! So, it looks like that:
instead of something like this:
I'm aware of lxml which seems to have a pretty print option, but I would
prefer to use the standard-lib Element