Java 和 dom (org.dom4j)
我正在使用一些库:org.dom4j。我是JAVA初学者。我想知道如何获取节点书中的所有子项(我有部分,其他信息中的作者(不是所有书籍节点中的一些))
java.util.List BookList = xmlDocument.selectNodes("/BooksList/Books");
Iterator Biterator = BookList .iterator();
while(Biterator.hasNext()){
Element book = null;
book = (Element)Biterator.next();
}
XML:
<BooksList>
<Books name="Three kingdom">
<author name="Title">
<sections number="216">
</Books>
<Books name="Frog and king">
<author name="Title s">
<sections number="21">
<pages number="421">
<Books>
</BooksList>
I am using some library: org.dom4j. I am beginer in JAVA. I want to know how get all childs in Node Books (i have sections, author in other info (not the some in all books node))
java.util.List BookList = xmlDocument.selectNodes("/BooksList/Books");
Iterator Biterator = BookList .iterator();
while(Biterator.hasNext()){
Element book = null;
book = (Element)Biterator.next();
}
XML:
<BooksList>
<Books name="Three kingdom">
<author name="Title">
<sections number="216">
</Books>
<Books name="Frog and king">
<author name="Title s">
<sections number="21">
<pages number="421">
<Books>
</BooksList>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许这有帮助:
http:// /www.jdom.org/docs/apidocs/org/jdom/Element.html#getChildren(java.lang.String)
http://www.cafeconleche.org/books/xmljava/chapters/ch14s08.html
Maybe this helps:
http://www.jdom.org/docs/apidocs/org/jdom/Element.html#getChildren(java.lang.String)
http://www.cafeconleche.org/books/xmljava/chapters/ch14s08.html