寻找 JDOM2 XPath 示例 [英] Looking for JDOM2 XPath examples
问题描述
我是第一次使用 JDOM2,我正在寻找一些基于 XPATH 的示例.
I am using JDOM2 for the first time and I am looking for some XPATH based examples.
例如:我的 XML 如下所示
Ex: My XML looks as follows
<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>
我的背景是 .NET &使用 System.XML 可以更轻松地进行 XPATH 遍历
My background is .NET & XPATH traversing is very easier with System.XML
我正在开发一个需要使用 XML 的(新手)Java 应用程序.我打算使用 JDOM2.我想使用 DOM 解析而不是 SAX.
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.
我正在寻找一些关于如何将 XPATH 与 JDOM2 结合使用的示例.
I am looking for some examples on how to use XPATH with JDOM2.
例如.我如何导航到一个元素,比如 "/Root/Parent[@id='2']/Child[@id='3']"
Ex. How can I navigate to an element let's say "/Root/Parent[@id='2']/Child[@id='3']"
你们能给我举一些例子吗?我搜索过,但找不到 JDOM2
Can you guys give me some examples? I searched but I couldn't find one for JDOM2
推荐答案
好的,找到了 https://github.com/hunterhacker/jdom/wiki/JDOM2-A-Primer 似乎有帮助
Ok, found this https://github.com/hunterhacker/jdom/wiki/JDOM2-A-Primer and seem to be helpful
这篇关于寻找 JDOM2 XPath 示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!