my scripts heavily use the function "doc.evaluate(xpath, node, null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)".
it works with 3.5, but NOT with 3.6.
my code sample :
var XPFirst = XPathResult.FIRST_ORDERED_NODE_TYPE;
var XPList = XPathResult.ORDERED_NODE_SNAPSHOT_TYPE;
function getSnapshotItem(resText, xpath, xpType){
if (xpType==null) xpType = XPFirst;
var aDoc = document.implementation.createDocument("", "", null);
var aElem = document.createElement('DIV');
aElem.innerHTML = resText;
aDoc.appendChild(aElem);
var ret = aDoc.evaluate(xpath, aElem, null, xpType, null);
return xpType==XPFirst ? ret.singleNodeValue : ret;
}
function onSpielerComplete(XMLHttpRequest, textStatus){
if (textStatus=="success"){
var table = getSnapshotItem(XMLHttpRequest.responseText, "//table
[@id='villages']");
}
}
in firefox 3.5, i can get table as a table dom element
but in firefox 3.6, table == null !
Could anyone please help ?
I don't see anything obviously wrong, so I'd just install Firebug on
both 3.5 and 3.6, then either step through the code or add appropriate
console.log calls and figure out where things first differ. For example,
are resText and aDoc the same in both cases?
Brian
<script>
window.onload = function(){
var aDoc = document.implementation.createDocument("", "", null);
var aElem = document.createElement('DIV');
aElem.innerHTML = "<table id='ptable'><tr><td>this is a table</td></
tr></table>";
aDoc.appendChild(aElem);
var ret = aDoc.evaluate("//table[@id='ptable']", aElem, null,
XPathResult.FIRST_ORDERED_NODE_TYPE, null);
alert("navigator.userAgent : " + navigator.userAgent + "\r\n\r\n" +
"ret.singleNodeValue : " + ret.singleNodeValue);
}
</script>
This html will alert ret.singleNodeValue content
in 3.5 : ret.singleNodeValue : [object HTML TableElement]
in 3.6 : ret.singleNodeValue : null
i maked a test link here :
http://chin99.myweb.hinet.net/code/test_xpath.html
Need Help Plz ! Thanks a lot !
What was the problem with this one?
On Feb 5, 9:53 am, Angus <angus...@gmail.com> wrote:
> http://angusdev.blogspot.com/2010/02/fixing-xpath-problem-in-firefox-...
var pulleddoc = document.implementation.createDocument("", "", null);
pulleddoc.appendChild(pulled);
ex = "//ns:p[@class="error"]';
err = pulleddoc.evaluate(ex,pulled,nsResolver,
XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;
GM_log(pulled.innerHTML);
alert(err.innerHTML);
not working :( what i'm doing wrong ?
(ofc both functions are defined)6.