ElementTree.findtext()

Discussion in 'Python' started by Richie Hindle, Jan 21, 2005.

  1. Hi,

    I can't get ElementTree.findtext() to work with anything other than a
    single-level path:

    >>> from elementtree import ElementTree
    >>> tree = ElementTree.fromstring("""\

    .... <?xml version='1.0' encoding='us-ascii'?>
    .... <html>
    .... <head>
    .... <title>The title</title>
    .... </head>
    .... </html>
    .... """)
    >>> print tree.findtext("*/title")

    The title
    >>> print tree.findtext("html/head/title")

    None
    >>>


    What am I missing?

    I'm using elementtree-1.2.4-20041228 on Windows with Python 2.3.

    --
    Richie Hindle <>
     
    Richie Hindle, Jan 21, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tim Arnold

    elementtree behavior

    Tim Arnold, Sep 27, 2004, in forum: Python
    Replies:
    2
    Views:
    257
    Fredrik Lundh
    Sep 27, 2004
  2. Jesper Olsen

    elementtree -

    Jesper Olsen, Oct 3, 2004, in forum: Python
    Replies:
    2
    Views:
    548
    Jesper Olsen
    Oct 4, 2004
  3. cvk
    Replies:
    0
    Views:
    1,452
  4. borntonetwork
    Replies:
    2
    Views:
    743
    borntonetwork
    Mar 3, 2007
  5. Kee Nethery
    Replies:
    12
    Views:
    2,133
    Stefan Behnel
    Jun 27, 2009
Loading...

Share This Page