<[EMAIL PROTECTED]> wrote:

> <abcd label="ABC">

> </abcd>
> .
> .
> <xyz label="A1">

> </xyz>
>
> ..
> and so on

an XML document can only have a single root element, but your example
has at least two top-level elements (abcd and xyz).

here is some elementtree code that handles this by wrapping your data in
a "root" element.

from elementtree import ElementTree

p = ElementTree.XMLTreeBuilder()

p.feed("<root>")
p.feed(open("mydocument.xml").read())
p.feed("</root>")

root = p.close()

def printelem(elem, prefix=""):
    label = elem.get("label")
    if label:
        if not prefix:
            print
        print prefix + label
    for elem in elem:
        printelem(elem, prefix + "..")

for elem in root:
    printelem(elem)

# end

the elementtree library can be found here:

    http://effbot.org/zone/element-index.htm

</F> 



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to