identifying and parsing string in text file

bruno.desthuilliers at gmail.com bruno.desthuilliers at gmail.com
Sun Mar 9 09:16:51 EDT 2008


On 8 mar, 20:49, "Bryan.Fodn... at gmail.com" <Bryan.Fodn... at gmail.com>
wrote:
> I have a large file that has many lines like this,
>
> <element tag="300a,0014" vr="CS" vm="1" len="4"
> name="DoseReferenceStructureType">SITE</element>
>
> I would like to identify the line by the tag (300a,0014) and then grab
> the name (DoseReferenceStructureType) and value (SITE).

It's obviously an XML file, so use a XML parser - there are SAX and
DOM parsers in the stdlib, as well as the ElementTree module.




More information about the Python-list mailing list