[Tutor] how to extract text by specifying an element using ElementTree

Kent Johnson kent37 at tds.net
Fri Dec 9 20:42:10 CET 2005


Srinivas Iyyer wrote:
> Hi group,
>   I just have another question in parsin XML files. I
> found it very easy to parse XML files with kent and
> danny's help. 
> 
> I realized that all my XML files have '\t' and '\n'
> and whitespace.  these extra features are making to
> extract the text data from the xml files very
> difficult.  I can make these XML parser work when I
> rekove '\n' and '\t' from xml files. 
> 
> is there a way to get rid of '\n' and '\t' characters
> from xml files easily. 

Did you see how I did this in my original example? I called strip() on 
the text part of the element. This removes leading and trailing 
whitespace. Is that what you need?

Kent



More information about the Tutor mailing list