Actually, that's not "raw data" coming in, that's valid XML. Why do you need to indent it? Just write it to a file.
If you really need to indent XML, get BeautifulSoup, read the XML in with BeautifulStoneSoup, and write it back out with "prettify()". But if the next thing to see that XML is a program, not a human, why bother? John Nagle Justin Ezequiel wrote: > On Jan 30, 10:42 am, [EMAIL PROTECTED] wrote: > >>For example the raw data is as follows >> >><?xml version="1.0" ?><Blah><ABC><Id id="1"/><Description>SomeText </ >>Description><Result>PassorFail</Result></ABC></Blah> >> >>without spaces or new lines. I need this to be written into an XML >>file as >> >><?xml version="1.0" ?> >><Blah> >> <ABC> >> <Id id="1"/> >> <Description> >> SomeText >> </Description> >> <Result> >> PassorFail >> </Result> >> </ABC> >></Blah> >> > > raw = r'<?xml version="1.0" ?><Blah><ABC><Id id="1"/ > >><Description>SomeText </Description><Result>PassorFail</Result></ > > ABC></Blah>' > import xml.dom.ext > import xml.dom.minidom > doc = xml.dom.minidom.parseString(raw) > xml.dom.ext.PrettyPrint(doc) > <?xml version='1.0' encoding='UTF-8'?> > <Blah> > <ABC> > <Id id='1'/> > <Description>SomeText </Description> > <Result>PassorFail</Result> > </ABC> > </Blah> > > -- http://mail.python.org/mailman/listinfo/python-list