Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: why the conut( ) can not get the number?

Reply
Thread Tools

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

 
 
Peter Otten
Guest
Posts: n/a
 
      12-10-2012
水静流深 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)")

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why :: ? Why not : ? Why not . ? <- less clutter ?!? Skybuck Flying C++ 16 08-25-2007 09:48 PM
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
why why why does function not work Horace Nunley ASP .Net 1 09-27-2006 09:52 PM



Advertisments