XPATH
来源:互联网 发布:应用统计学专业知乎 编辑:程序博客网 时间:2024/05/01 11:17
The XPath language provides a simple, concise syntax for selectingnodes from an XML document. XPath also provides rules for converting anode in an XML document object model (DOM) tree to a boolean, double,or string value. XPath is a W3C-defined language and an official W3Crecommendation; the W3C hosts the XML Path Language (XPath) Version1.0 specification.
XPath Context
XPath location paths may be relative to a particular node in thedocument, known as thecontext
. Consider the followingXML document:
<widgets><widget><manufacturer/><dimensions/></widget></widgets>
The <widget>
element can be selected with thefollowing XPath API code:
// parse the XML as a W3C DocumentDocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();Document document = builder.parse(new File("/widgets.xml"));XPath xpath = XPathFactory.newInstance().newXPath();String expression = "/widgets/widget";Node widgetNode = (Node) xpath.evaluate(expression, document, XPathConstants.NODE);
With a reference to the <widget>
element, arelative XPath expression can now written to select the<manufacturer>
child element:
XPath xpath = XPathFactory.newInstance().newXPath();String expression = "manufacturer";Node manufacturerNode = (Node) xpath.evaluate(expression, widgetNode, XPathConstants.NODE);
0 0
- xpath
- XPATH
- XPATH
- XPATH
- xpath
- XPath
- xPath
- Xpath
- XPath
- XPath
- XPath
- xpath
- Xpath
- xpath
- XPATH
- XPath
- XPath
- xPath
- 通过 Intent 传递类对象
- LinearLayout 组件居中显示
- Eclipse使用Maven创建Web时错误:Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webap
- 【转】Google推荐的图片加载库Glide介绍
- iOS打电话功能
- XPATH
- angularjs 和 trim方法冲突
- Java 完美判断中文字符
- 阿里云CentOS 7.1使用yum安装MySql5.6.24
- Linux挂载windows共享文件夹
- Leetcode171. Excel Sheet Column Number
- 表格等分页查询 后台控制器的操作
- 二维DCT变换
- 创建本地yum仓库