JS中常用的xpath特性
//选择所有dir元素的值等于xx的元素
Dom.documentElement.selectNodes("server/dir[text()='xx']")
//选择server元素下的所有dir元素:
Dom.documentElement.selectNodes("server/dir")
//选择server元素下的第一个dir元素:
Dom.documentElement.selectSingleNode("server/dir");
//选择server元素下accesstype等于3的多有dir元素:
Dom.documentElement.selectNodes("server/dir[@accesstype=\"3\"]");
//选择server元素下第一个dir元素:
Dom.documentElement.selectNodes("server[postion() =1]/dir");
Dom.documentElement.selectNodes("server/dir[1]");
//选择server元素下最后一个dir元素:
Dom.documentElement.selectNodes("server/dir[last()]");
//选择有三个祖先元素的file元素:
Dom.documentElement.selectNodes("*/*/*/file");
//选择有id属性的dir元素:
Dom.documentElement.selectNodes("/dir[@id]");
//选择含有2个dir子元素的元素
Dom.documentElement.selectNodes("/*[count(dir)=2]");
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)