Martin Honnen ha scritto:
MSXML provides two methods, one called selectSingleNod e, the other
called selectNodes. Are you using one of these?
Thanks for answering Martin!
Yes, Im using selectNodes. Of course it works on IE, and in Mozilla
only if i add some code that redefine the working of this method; to be
precise, i add this code at the beginning of my script
if( document.implem entation.hasFea ture("XPath", "3.0") )
{
// prototying the XMLDocument
XMLDocument.pro totype.selectNo des = function(cXPath String, xNode)
{
if( !xNode ) { xNode = this; }
var oNSResolver = this.createNSRe solver(this.doc umentElement)
var aItems = this.evaluate(c XPathString, xNode, oNSResolver,
XPathResult.ORD ERED_NODE_SNAPS HOT_TYPE, null)
var aResult = [];
for( var i = 0; i < aItems.snapshot Length; i++)
{
aResult[i] = aItems.snapshot Item(i);
}
return aResult;
}
// prototying the Element
Element.prototy pe.selectNodes = function(cXPath String)
{
if(this.ownerDo cument.selectNo des)
{
return this.ownerDocum ent.selectNodes (cXPathString, this);
}
else{throw "For XML Elements Only";}
}
}
This doesnt work under Safari, since Xpath is not supported there; thus
should i write something similar for Safari? Honestly, i wouldnt know
where to start from...
I don't think Safari has XPath support so far thus if you really use
XPath expressions as arguments to that functions then you need to write
more code. For other simple tasks you might get away with using
getElementsByTa gName e.g. you can replace
Yes, I use xpath expressions as parameters for the selectNodes method
:(
So If i got it well, there are two options: rewriting my scripts with
getElementsByTa gName or redefining selectNodes. Which way do you think
is the best one?