社区
XML/XSL
帖子详情
关于Namespace的selectNodes("//x:aa/x:bb"),如果前缀x换了,那怎么办?
Lostinet
2002-04-28 12:20:49
条件是:已经知道x的namespace
...全文
102
6
打赏
收藏
关于Namespace的selectNodes("//x:aa/x:bb"),如果前缀x换了,那怎么办?
条件是:已经知道x的namespace
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
6 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
saucer
2002-04-28
打赏
举报
回复
xmldoc.setProperty("SelectionNamespaces",
"xmlns:x='http://myserver.com'");
saucer
2002-04-28
打赏
举报
回复
对不起,应该是
alert(nodes[i].prefix + "-" + nodes[i].baseName +"-" + nodes[i].namespaceURI);
saucer
2002-04-28
打赏
举报
回复
只要这里的两个x不是属于不同的命名空间就成,而且XMLDOM不太看前缀,譬如
<root xmlns:x='http://myserver2.com'>
<x:a>
<x:b xmlns:x='http://myserver.com'>
</x:b>
</x:a>
</root>
var xmldoc = new ActiveXObject("MSXML2.DOMDOCUMENT.4.0");
xmldoc.async = false;
xmldoc.load("some.xml");
xmldoc.setProperty("SelectionNamespaces",
"xmlns:x2='http://myserver2.com' xmlns:x='http://myserver.com'");
var nodes = xmldoc.selectNodes("//x2:a[x:b]");
for (var i=0; i < nodes.length; i++)
alert(nodes[0].prefix + "-" + nodes[i].baseName +"-" + nodes[i].namespaceURI);
显示:
x-a-http://myserver2.com
Lostinet
2002-04-28
打赏
举报
回复
那么如果已经有其他的了x了呢?会冲突么?
saucer
2002-04-28
打赏
举报
回复
var xmldoc = new ActiveXObject("MSXML2.DOMDOCUMENT.4.0");
xmldoc.async = false;
xmldoc.load("some.xml");
xmldoc.setProperty("SelectionNamespaces",
"xmlns:x='http://myserver.com'");
var nodes = xmldoc.selectNodes("//x:aa/x:bb");
nodes[0].prefix;
nodes[0].baseName;
nodes[0].namespaceURI;
Lostinet
2002-04-28
打赏
举报
回复
可以说详细点么?
--------------------
如果在dom中,我知道了根节点的某个namespace,那么我可以得到prefix么?
华为荣耀recovery1.0
源码链接: https://pan.quark.cn/s/a4b39357ea24 This directory contains a script ('makefsdata') to create C code suitable for httpd for given html pages (or other files) in a directory. There is also a plain C console application doing the same and extended a bit. Usage: htmlgen [targetdir] [-s] [-i]s targetdir: relative or absolute path to files to convert switch -s: toggle processing of subdirectories (default is on) switch -e: exclude HTTP header from file (header is created at runtime, default is on) switch -11: include HTTP 1.1 header (1.0 is default) if targetdir not specified, makefsdata will attempt to process files in subdirectory 'fs'.
光纤耦合器Matlab模拟.rar
光纤耦合器Matlab模拟.rar
ModbusDoctor软件
官网下载地址:需墙:https://www.kscada.com/modbusdoctor.html 使用非常简单,并且免费、免安装 Modbus Doctor(强烈推荐) 下载地址:搜索 “Modbus Doctor” 官网或 GitHub 界面现代化,支持中文,操作和 Modbus Poll 很像
XML/XSL
8,906
社区成员
22,677
社区内容
发帖
与我相关
我的任务
XML/XSL
XML/XSL相关问题讨论专区
复制链接
扫一扫
分享
社区描述
XML/XSL相关问题讨论专区
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章