From: Aaron Patterson Date: 2010-07-05T13:35:12+09:00 Subject: Re: strange xpath output --+QahgC5+KEYLbs62 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 05, 2010 at 11:00:38AM +0900, Pen Ttt wrote: > /home/pt/jiexi content is: > >=20 > require 'rubygems' > require 'nokogiri' > doc =3D Nokogiri::HTML.parse(open('/home/pt/jiexi')) > table=3Ddoc.xpath('//ul[@id=3D"ul_list"]/li/a') > puts table > output > irb(main):005:0> puts table > > > > > =3D> nil > puts table.xpath('//ul') > irb(main):006:0> puts table.xpath('//ul') > >=20 > what i think is the script "puts table.xpath('//ul')" will not create > any output. > how strange it is to get the result,would you mind to tell me why? "//ul" says "find all ul tags anywhere in the document". It looks like you have a ul tag in your document, and the XPath is doing what it is supposed to do. Why would you expect "//ul" to have no results? --=20 Aaron Patterson http://tenderlovemaking.com/ --+QahgC5+KEYLbs62 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (Darwin) iQEcBAEBAgAGBQJMMWDvAAoJEJUxcLy0/6/Gz/4IAKJTRsiMR9gfts1qxby+5M8x Ph0qcjn2PWB1zuml4rfNomBfTAco0lQNi+0XfIFh57xqOLoWLNY2o3S4p4EMtJAs IHa/kHT4zZFsYXPP7QMLtcbEcYr4WWOVpRe/NqEu5iQjO0zq9zOaM21xZKER0XrM DrDs6/VbVLzwA5UuxZQVNpIP3qCA2OJeK/gVHjfu9Gl04EmF57aESk1wfsNjAYzS YCzjhyGeucbO6muLhcZVycjxq4PGnfuMbucCGg3TxtEBEQxomSMKISI26WYzIDG2 eCoG4afEm6aZa4ffellrj+vTBe5oCjY6xFMYBxKRWv0UVbKxtEq9w84GVKM/+3Y= =kF2j -----END PGP SIGNATURE----- --+QahgC5+KEYLbs62--