Re: why the conut( ) can not get the number?

Discussion in 'Python' started by Peter Otten, Dec 10, 2012.

  1. Peter Otten

    Peter Otten Guest

    æ°´é™æµæ·± wrote:

    > i wnat to get the number of a atrributes in a xpath,here is my code,why i
    > can not get the number ? import urllib
    > import lxml.html
    > down="http://python-gtk-3-tutorial.readthedocs.org/en/latest/index.html"
    > file=urllib.urlopen(down).read()
    > root=lxml.html.document_fromstring(file)
    > for order,node in enumerate(root.xpath('//li[@class="toctree-l1"]')):
    > print order,node.xpath('.//a[count(*)]')


    This looks more like an xpath than a python problem. I'm no xpath expert --
    and you don't describe the expected outcome -- maybe you want

    print order, node.xpath("count(.//a)")
    Peter Otten, Dec 10, 2012
    #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. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    863
    Mark Rae
    Dec 21, 2006
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,763
    Smokey Grindel
    Dec 2, 2006
  3. Jekyll
    Replies:
    2
    Views:
    419
    Victor Bazarov
    Apr 24, 2007
  4. Skybuck Flying
    Replies:
    16
    Views:
    659
    tragomaskhalos
    Aug 25, 2007
  5. Ë®¾²Á÷Éî

    why the conut( ) can not get the number?

    Ë®¾²Á÷Éî, Dec 9, 2012, in forum: Python
    Replies:
    0
    Views:
    74
    Ë®¾²Á÷Éî
    Dec 9, 2012
Loading...

Share This Page