0

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>
2
  • 2
    Looks like you have some unclosed tags in your XML. Specifically <author>, <sections>, and <pages>. Commented Sep 20, 2010 at 13:25
  • Also, the last <Books> tag should be probably be a closing tag, not an opening tag. Commented Sep 20, 2010 at 14:45

1 Answer 1

1
List books = element.getChildren("Books");

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.