java 寻找 JDOM2 XPath 示例
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15541652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Looking for JDOM2 XPath examples
提问by KK99
I am using JDOM2 for the first time and I am looking for some XPATH based examples.
我第一次使用 JDOM2,我正在寻找一些基于 XPATH 的示例。
Ex: My XML looks as follows
例如:我的 XML 如下所示
<Root>
<Parent id="1">
<Child id="1" />
<Child id="2" />
<Child id="3" />
</Parent>
<Parent id="2">
<Child id="1" />
<Child id="2" />
<Child id="3" />
</Parent>
<Parent id="3">
<Child id="1" />
<Child id="2" />
<Child id="3" />
</Parent>
</Root>
My background is .NET & XPATH traversing is very easier with System.XML
我的背景是 .NET & XPATH 遍历使用 System.XML 非常容易
I am working on a (new to) Java application where I need to use XML. I am planning to use JDOM2. I want to use DOM parsing and not SAX.
我正在开发一个(新的)Java 应用程序,我需要在其中使用 XML。我打算使用 JDOM2。我想使用 DOM 解析而不是 SAX。
I am looking for some examples on how to use XPATH with JDOM2.
我正在寻找一些关于如何将 XPATH 与 JDOM2 一起使用的示例。
Ex. How can I navigate to an element let's say "/Root/Parent[@id='2']/Child[@id='3']"
前任。我如何导航到一个元素让我们说"/Root/Parent[@id='2']/Child[@id='3']"
Can you guys give me some examples? I searched but I couldn't find one for JDOM2
大家能给我举几个例子吗?我搜索过,但找不到 JDOM2
回答by KK99
Ok, found this https://github.com/hunterhacker/jdom/wiki/JDOM2-A-Primerand seem to be helpful
好的,找到了这个https://github.com/hunterhacker/jdom/wiki/JDOM2-A-Primer并且似乎有帮助
回答by mithil-studytrails
http://www.studytrails.com/java/xml/jdom2/java-xml-jdom2-xpath/
http://www.studytrails.com/java/xml/jdom2/java-xml-jdom2-xpath/
is an example of using JDOM2 and XPATH
是使用 JDOM2 和 XPATH 的示例