华为ensp中USG6000V防火墙双机热备VRRP+HRP原理及配置
    示例代码:
 
xml:
  
 
<?xml version="1.0" encoding="UTF-8"?>
<books>
    <book id="0001">
        <name>JavaWeb开发教程</name>
        <author>张孝祥</author>
        <sale>100.00元</sale>
    </book>
    <book id="0002">
        <name>三国演义</name>
        <author>罗贯中</author>
        <sale>100.00元</sale>
    </book>
</books>
 
获取xml内容:
 
public class Dom4jParseTest1 {
    public void testDom4j() throws DocumentException {
        /*使用SaxReader类,加载xml文件,并创建Document对象*/
        Document doc = new SAXReader().read("src/books.xml");
        Element rootElement = doc.getRootElement();  //使用document对象,获取到dom树的根节点
        List<Element> bookList = rootElement.elements("book");//基于根元素,获取所有的子元素
        /*遍历:所有的子元素*/
        for (Element bookElement : bookList) {
            Element nameEl = bookElement.element("name");  //获取name元素
            String nameText = nameEl.getText(); //获取name元素中的文本内容
            System.out.println(nameText);
            String idValue = bookElement.attributeValue("id"); //获取book元素上的id属性值
            System.out.println("id="+idValue);
            
            String authorText = bookElement.elementText("author");//获取作者元素下的文本内容
            System.out.println(authorText);
        }
    }
}
 
注意:需要下载并且导入dom4j-2.1.1.jar包,或者使用maven加载。