admin管理员组文章数量:1415484
Why is this code giving me the following error on IE: "Unknown Method. //author[@select = -->concat('tes'<--,'ts')]?
function a()
{
try
{
var xml ='<?xml version="1.0"?><book><author select="tests">blah</author></book>';
var doc = new ActiveXObject("Microsoft.XMLDOM");
doc.loadXML(xml);
node = doc.selectSingleNode("//author[@select = concat('tes','ts')]");
if(node == null)
{
alert("Node is null");
}
else
{
alert("Node is NOT null");
}
} catch(e)
{
alert(e.message);
}
}
Why is this code giving me the following error on IE: "Unknown Method. //author[@select = -->concat('tes'<--,'ts')]?
function a()
{
try
{
var xml ='<?xml version="1.0"?><book><author select="tests">blah</author></book>';
var doc = new ActiveXObject("Microsoft.XMLDOM");
doc.loadXML(xml);
node = doc.selectSingleNode("//author[@select = concat('tes','ts')]");
if(node == null)
{
alert("Node is null");
}
else
{
alert("Node is NOT null");
}
} catch(e)
{
alert(e.message);
}
}
Share
Improve this question
asked May 9, 2012 at 18:46
AbdulAbdul
4197 silver badges15 bronze badges
1
-
Please fix your error message so that it's legible. Is
concat
a function? – Madbreaks Commented May 9, 2012 at 18:49
1 Answer
Reset to default 5Well Microsoft.XMLDOM
is an antiquated programming id and you end up with an old MSXML version that by default does not support XPath 1.0 but rather an old, never standardized draft version. These days MSXML 6 is part of any OS or OS with latest service pack that Microsoft supports so simply consider to use an MSXML 6 DOM document with e.g.
var xml ='<?xml version="1.0"?><book><author select="tests">blah</author></book>';
var doc = new ActiveXObject("Msxml2.DOMDocument.6.0");
doc.loadXML(xml);
node = doc.selectSingleNode("//author[@select = concat('tes','ts')]");
if(node == null)
{
alert("Node is null");
}
else
{
alert("Node is NOT null");
}
If you insist on using Microsoft.XMLDOM
then call doc.setProperty("SelectionLanguage", "XPath")
before any selectSingleNode
or selectNodes
calls trying to use XPath 1.0.
本文标签: xpathJavaScript on IE9 XMLDOMselectSingleNode gives Unknown method gtconcatStack Overflow
版权声明:本文标题:xpath - JavaScript on IE9. XMLDOM.selectSingleNode gives Unknown method -->concat - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745232676a2648895.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论