Problem with readlines() and uml

Bruno Desthuilliers onurb at xiludom.gro
Wed Jul 26 09:01:36 EDT 2006


wscrsurfdude wrote:

> Sorry it is so hot in here, I make mistakes, I meant it to be an xml
> file. But still sthe same problem

> 
>>Ik have an xml file I want to read with readlines. I have the following
>>code:
>>infile = open("out2.txt","r")
>>for line in infile.readlines():
>>    print line
>>
>>The print statement just gives the data, not the xml headings. 

Still the same question : what is an "xml heading" ? xml is a textual
markup language. It has elements ('tags') which can have content and
attributes -  but nothing like "headings".

file.readlines() iterates over lines of a opened text file - it doesn't
give a damn about what this text is, xml, python code, csv or whatever.
If your file contains xml and you want to interpret the xml, you have to
use a xml parser.

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list