Luis P. Mendes wrote:
with:    DataSetNode = stringNode.childNodes[0]
    print DataSetNode.toxml()

I get:

<DataSet>
~  <Order>
~    <Customer>439</Customer>

~  </Order>
</DataSet>
_______________________________________________________________-

so far so good, but when I issue the command:

print DataSetNode.childNodes[0]

I get:
IndexError: tuple index out of range

Why the error, and why does it return a tuple?

The DataSetNode has no children, because it is not an Element node, but a Text node. In XML, an element is denoted by

  <DataSet>...</DataSet>

and *not* by

  &lt;DataSet&gt;...&lt;/DataSet&gt;

The latter is just a single string, represented
in XML as a Text node. It does not give you any
hierarchy whatsoever.

As a text node does not have any children, its
childNode members is a empty tuple; accessing
that tuple gives you an IndexError.

Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to