Jeff Johnson wrote:
> In order to load an xml document into a parser I need to strip '\n' and
> '\r', This is how I am doing it and it works:
>
> f = open(sys.argv[1], 'r')
> s = f.read()
> f.close()
> # remove returns
> s = s.replace('\n', '')
> s = s.replace('\r', '')
> o = open('testo.imf', 'w')
> o.write(s)
> o.close()
>
> Is there a better way? IOW perform the stripping directly on the input
> file?
Which XML parser can't handle newlines?
Try:
"""
out = open('testo.imf', 'wb')
for line in open(sys.argv[1]):
out.write(line.replace('\n', '').replace('\r', ''))
out.close()
"""
Paul
--
http://paulmcnett.com
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/dabo-users/[EMAIL PROTECTED]