

public class FileDemo {
public static void main(String[] args) throws Exception {
SAXReader saxReader = new SAXReader()
InputStream is = FileDemo.class.getResourceAsStream("/app.xml")
Document document = saxReader.read(is)
Element root = document.getRootElement()
System.out.println(root.getName())
// List<Element> sonElement = root.elements()
List<Element> sonElement = root.elements("contact")
for (Element element : sonElement) {
System.out.println(element.getName())
}
Element userEle = root.element("user")
System.out.println(userEle.getName())
Element contact = root.element("contact")
System.out.println(contact.elementText("name"))
System.out.println(contact.elementTextTrim("name"))
Element email = contact.element("email")
System.out.println(email.getText())
Attribute vipAttr = contact.attribute("vip")
System.out.println(vipAttr.getName() + "->" + vipAttr.getValue())
System.out.println("id" + "->" + contact.attributeValue("id"))
}
}