Hi all:
when I use XPather(a firefox extension) to evaluate the expression:
"/html/body/table[3]/tbody/tr/td[2]/table/tbody/tr/td/div/ul[1]/li"
it tells me there are 7 matching Nodes.
but when I use the following code to do the same thing:
nodes =
document.evalua te("/html/body/table[3]/tbody/tr/td[2]/table/tbody/tr/td/div/ul[1]/li",
document, null,XPathResul t. ORDERED_NODE_SN APSHOT_TYPE , null);
len = nodes.snapshot( 0).childNodes.l ength;
the len returns 2.
so the XPather and firefox javascript returns different results,
generally I think the result of XPather is right. I can't tell why
javascript returns 2 here
Appreciate your help!
the site I test the expression is : http://www.amazon.com/exec/obidos/AS...667641-1219860 1 1907
shellon wrote:
when I use XPather(a firefox extension) to evaluate the expression:
"/html/body/table[3]/tbody/tr/td[2]/table/tbody/tr/td/div/ul[1]/li"
it tells me there are 7 matching Nodes.
but when I use the following code to do the same thing:
nodes =
document.evalua te("/html/body/table[3]/tbody/tr/td[2]/table/tbody/tr/td/div/ul[1]/li",
document, null,XPathResul t. ORDERED_NODE_SN APSHOT_TYPE , null);
len = nodes.snapshot( 0).childNodes.l ength;
the len returns 2.
so the XPather and firefox javascript returns different results,
generally I think the result of XPather is right. I can't tell why
javascript returns 2 here
The evaluate method returns an XPathResult object, to check the length
of a snapshot returned you need to use e.g.
var xPathResult =
document.evalua te("/html/body/table[3]/tbody/tr/td[2]/table/tbody/tr/td/div/ul[1]/li",
document, null, XPathResult.ORD ERED_NODE_SNAPS HOT_TYPE, null);
and then you can evaluate xPathResult.sna pshotLength which should then
give you the number of nodes (e.g. 7).
--
Martin Honnen http://JavaScript.FAQTs.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kepler |
last post by:
How do you get the height of the client browser in IE? Both
document.body.clientHeight and document.body.offsetHeight return the
height of the document. If the page is long and there's a vertical
scrollbar, you get the height of the entire document, screwing up any
chance of centering a window in the browser using these values.
Is there a way to get the height of the actual browser window and not
the entire page height?
Thanks.
|
by: Stumped and Confused |
last post by:
Hello,
I really, really, need some help here - I've spent hours trying to find a
solution.
In a nutshell, I'm trying to have a user input a value in form's
textfield. The value should then be assigned to a variable and output
using document.write.
(Note, there is no submit button or other form elements. Basically
|
by: james.kingston |
last post by:
In my first experimentation with js, I'm writing a greasemonkey script
which adds links to a page which, when clicked, will replace their
parent element with the contents of an element from another URL.
in the following function, pageHTML contains the entire text of an HTML
page, pulled in via GM_xmlhttprequest. The page contains a ul with
id="commentlisting". What I want to do, but can't seem to do, is turn
that lump of html in the...
|
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their code
was littered with document.all and eval, for example, and I wanted to create
a practical list of best practices that they could easily put to use.
The above URL is version 1.0 (draft) that resulted. IMO, it is not a
replacement for the FAQ,...
|
by: Csaba Gabor |
last post by:
In Firefox 1.5 (this question is Mozilla specific as I am using
greasemonkey) I would like to be able to use document.evaluate to
return the first TD entry that shows ^\s*MySearchText\s*$. As I
understand it, xpath doesn't yet have regular expressions so I thought
to do:
function findNode (srch) {
var node;
var expr="//td";
var RE = new RegExp("\\s*" + srch + "\\s*$");
| |
by: weston |
last post by:
I've got a piece of code where, for all the world, it looks like this
fails in IE 6:
hometab = document.getElementById('hometab');
but this succeeds:
hometabemt = document.getElementById('hometab');
Has anyone ever seen anything like this before, or am I dreaming?
|
by: ppcguy |
last post by:
i've got this in firefox and it works
var xpath_result = document.evaluate("id('main')/tbody", document, null,
XPathResult.FIRST_ORDERED_NODE_TYPE, null );
var table = xpath_result.singleNodeValue;
what's the IE equivalent of it.
thx.
|
by: Björn Langhof |
last post by:
Hello.
I want to evaluate a XPath-Expression only on a subtree of the whole
xml-document.
1. I select a node of the XML-document
2. Then a want to select specific nodes below the node chosen in 1.
I thought the parameter contextNode in
var xpathResult = document.evaluate(xpathExpression, contextNode,
|
by: shellon |
last post by:
Hi all:
I met a problem when using document.evaluate() to get text content
using XPath,
my code is as follows:
nodes = document.evaluate("/html/body/div/ul/li", document,
null,XPathResult. UNORDERED_NODE_SNAPSHOT_TYPE , null);
in the XPath expression "/html/body/div/ul/li", I need to
traverse from li to li,
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |