View Full Version : XPATH Function - contains
netgouki
01-16-2004, 04:45 AM
Hi,
I have a problem in using DOMElement.singleNodes with function "contains" in Javascript.
I write the xPath Syntax as
"match[contains(team/teamID, 'ABC')]"
here's the XML:
<match>
<team>
<teamID>ABCD</teamID>
<teamName>ABCD United</teamNAME>
</team>
</match>
By an error "unknown method" occured.
What's the problem? Thank you very much.
I've never seen that function before — are you sure it exists? Try checking:alert([elementsname].singleNodes);(eg, if your element was called foo, then you'd call alert(foo.singleNodes)
brothercake
01-17-2004, 06:52 PM
Internet Explorer has a contains() method, but it's proprietary to IE. You can prototype your own like this (courtesy of jkd):
HTMLElement.prototype.contains = function(node)
{
if (node==null) { return false; }
if (node==this) { return true; }
else { return this.contains(node.parentNode); }
}
Originally posted by brothercake
Internet Explorer has a contains() method, but it's proprietary to IE. But contains() is an in-built XPath method, which means it takes place with XSLT on the server. I've used it before with no problems.
liorean
01-18-2004, 02:15 PM
DOMElement.singleNodes? There is a DOMElement.singleNodeValue, but no DOMElement.singleNodes, at least not in either of [DOM3 Core] and [DOM3 XPath]. The contains function is XPath, though. See <http://www.w3.org/TR/xpath#function-contains>.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.