Bottleneck? More efficient regular expression?
Fredrik Lundh
fredrik at pythonware.com
Wed Sep 24 04:44:32 EDT 2003
Andrew Dalke wrote:
> Another approach is to turn the XML into a DOM but I
> have much less experience with that. (I get confused with
> the DOM API every time I try
the DOM API is designed for consultants, not for humans or
computers.
here's the elementtree version, btw:
s = """<record>
<code>1cg2</code>
<chain>a</chain>
<settings>abcde</settings>
<scoreInfo>12345</scoreInfo>
<targetSeq name="1onc">blah
</targetSeq>
<alignment size="335"/>
<target>WLTFQKKHITNTRDVDCDNIMS</target>
<align> :| ..| : . | . |. . :</align>
<template>QKRDNVLFQAATDEQPAVIKTLEKL</template>
<anotherTag>foobarfoobar</anotherTag>
<yetAnotherTag>barfoobarfoo</yetAnotherTag>
</record>"""
from elementtree.ElementTree import XML
for node in XML(s):
print node.tag, "=", repr(node.text)
(more here: http://effbot.org/zone/element-index.htm )
</F>
More information about the Python-list
mailing list