JS中常用的xpath特性

摘要:
//选择元素Dom.documentElement。selectNodes(“server/dir[text()='xx']”),所有dir元素的值等于xx//选择服务器元素下的所有dir元素:Dom.documentElement。selectNodes(“server/dir”)//选择server元素下的第一个dir元素:Dom.documentElement。selectSingle
//选择所有dir元素的值等于xx的元素    
JS中常用的xpath特性第1张
Dom.documentElement.selectNodes("server/dir[text()='xx']")    
JS中常用的xpath特性第1张   
JS中常用的xpath特性第1张
//选择server元素下的所有dir元素:    
JS中常用的xpath特性第1张
Dom.documentElement.selectNodes("server/dir")    
JS中常用的xpath特性第1张   
JS中常用的xpath特性第1张
//选择server元素下的第一个dir元素:    
JS中常用的xpath特性第1张
Dom.documentElement.selectSingleNode("server/dir");    
JS中常用的xpath特性第1张   
JS中常用的xpath特性第1张
//选择server元素下accesstype等于3的多有dir元素:    
JS中常用的xpath特性第1张
Dom.documentElement.selectNodes("server/dir[@accesstype=\"3\"]");    
JS中常用的xpath特性第1张   
JS中常用的xpath特性第1张
//选择server元素下第一个dir元素:    
JS中常用的xpath特性第1张
Dom.documentElement.selectNodes("server[postion() =1]/dir");    
JS中常用的xpath特性第1张Dom.documentElement.selectNodes(
"server/dir[1]");    
JS中常用的xpath特性第1张   
JS中常用的xpath特性第1张
//选择server元素下最后一个dir元素:    
JS中常用的xpath特性第1张
Dom.documentElement.selectNodes("server/dir[last()]");    
JS中常用的xpath特性第1张   
JS中常用的xpath特性第1张
//选择有三个祖先元素的file元素:    
JS中常用的xpath特性第1张
Dom.documentElement.selectNodes("*/*/*/file");    
JS中常用的xpath特性第1张   
JS中常用的xpath特性第1张
//选择有id属性的dir元素:    
JS中常用的xpath特性第1张
Dom.documentElement.selectNodes("/dir[@id]");    
JS中常用的xpath特性第1张   
JS中常用的xpath特性第1张
//选择含有2个dir子元素的元素    
JS中常用的xpath特性第1张
Dom.documentElement.selectNodes("/*[count(dir)=2]");   

免责声明:文章转载自《JS中常用的xpath特性》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇2017.06.9 金融时间序列分析之Eview使用基础webdav 概览下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

[爬虫]采用Go语言爬取天猫商品页面

最近工作中有一个需求,需要爬取天猫商品的信息,整个需求的过程如下: 修改后端广告交易平台的代码,从阿里上传的素材中解析url,该url格式如下: https://handycam.alicdn.com/slideshow/26/7ef5aed1e3c39843e8feac816a436ecf.mp4?content=%7B%22items%22%3A%5B...

js正则表达式限制文本框只能输入数字,小数点,英文字母

1.文本框只能输入数字代码(小数点也不能输入)<input onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"> 2.只能输入数字,能输小数点.<input onkeyup="if...

JS阻止默认行为

如果事件可取消,则取消该事件,而不停止事件的进一步传播。 语法 event.preventDefault(); 案例 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>ev...

详解 JS 中 new 调用函数原理

JavaScript 中经常使用构造函数创建对象(通过 new 操作符调用一个函数),那在使用 new 调用一个函数的时候到底发生了什么?先看几个例子,再解释背后发生了什么。 1)看三个例子 1.1 无 return 语句 构造函数最后没有 return 语句,这也是使用构造函数时默认情况,最后会返回一个新对象,如下: function Foo(age)...

js压缩 uglify(2)

一、故事总有其背景 年末将至,很多闲适的时间,于是刷刷微博,接触各种纷杂的信息——美其名曰“学习”。运气不错,遇到了一个新名词,uglifyjs. 据说是用来压缩JS文件的,据说还能优化JS,据说是基于node的,还据说比Google Closure Compiler更带感,哦?激起了我的好奇心。百之谷之,哟,相关的介绍还不少。然后折腾了个把小时,基本上知...

JS刷新页面的几种方法

1 history.go(0)2 location.reload() 3 location=location 4 location.assign(location) 5 document.execCommand(‘Refresh‘) 6 window.navigate(location) 7 location.replace(location) 8 doc...