To: Matt Sergeant, matt@sergeant.org
Hi, Matt:
I noticed a bug in xpath from the XML::XPath module:
$ xpath XmlXPath.test.xml "//a[contains(@onmouseover,'topnext')]" Found 2 nodes:
Now, when I try to get the first node, it should return one node. But:
$ xpath XmlXPath.test.xml "//a[contains(@onmouseover,'topnext')][1]" Found 2 nodes: -- NODE -- <a border="0" onmouseover="iOver('topnext'); iOver('bottomnext'); self.status=nextblurb; return true;" onmouseout="iOut('topnext'); iOut('bottomnext'); self.status=''; return true;" href="l-grub-1-2.html"><img alt="Next" border="0" src="../i/next.gif" name="topnext" /></a>-- NODE -- <a border="0" onmouseover="iOver('topnext'); iOver('bottomnext'); self.status=nextblurb; return true;" onmouseout="iOut('topnext'); iOut('bottomnext'); self.status=''; return true;" href="l-grub-1-2.html"><img alt="Next" border="0" src="../i/next.gif" name="bottomnext" /></a>
However, when I tried to duplicate the error in the 05attrib.t, I failed. Due to my limited knowledge on Xml, and XML::XPath, I don't know where the problem is now. All I can guarantee is that the xml file is well formed. I'm sending the test file and my effort trying to duplicate the error (in 05attrib.t) to you, for you to have a look at your leisure time. There must be somewhere wrong.
Thanks
PS. attachment follows in a separated email. PPS. My XML::XPath is the latest, version 1.13.
> $ xpath XmlXPath.test.xml "//a[contains(@onmouseover,'topnext')]" > Found 2 nodes: > > Now, when I try to get the first node, it should return one node. But: > > $ xpath XmlXPath.test.xml "//a[contains(@onmouseover,'topnext')][1]" > Found 2 nodes:
You're misunderstanding what that [1] does. It applies to the local context of the <a> tag, not to that result set. You need brackets to set that context.
$ xpath XmlXPath.test.xml "(//a[contains(@onmouseover,'topnext')])[1]" Found 1 nodes: -- NODE -- <a border="0" onmouseover="iOver('topnext'); iOver('bottomnext'); self.status=nextblurb; return true;" onmouseout="iOut('topnext'); iOut('bottomnext'); self.status=''; return true;" href="l-grub-1-2.html"><img alt="Next" border="0" src="../i/next.gif" name="topnext" /></a>