<?xml version="1.0" encoding="UTF-8"?>
<books>
<book id="12">
<name>think in java</name>
<price>85.5</price>
<author>Edwrad Saverin</author>
</book>
<book id="15">
<name>Spring in Action</name>
<price>39.0</price>
<author>Edward Saverin</author>
</book>
</books>
NodeList bookNodes=element.getElementsByTagName("book");
for(int i=0;i<bookNodes.getLength();i++){
Element bookElement=(Element)bookNodes.item(i);
Book book=new Book();
book.setId(Integer.parseInt(bookElement.getAttribute("id")));
NodeList childNodes=bookElement.getChildNodes();
System.out.println("childnodes:"+childNodes.getLength());
为什么childnodes的长度为7?
POPMUISE
相关分类