Dom4j解析xml内容——(三)

时间:2022-09-01 20:45:04

Dom4j取标签中的内容用 getText ,取开始标签和结束标签之间的值。

取属性值有两种方式:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAosAAADbCAIAAACKmUyeAAAgAElEQVR4nO2dvW7jutPGdT17CSqc9yJOn8KBitzBFoH/hd2rCZBm0zlNygBCut0Arg4QIM2mcbHHTQKc1KfmW1Af/BgOqQ/bNP38IAS2KFEjippHM6ScTAAAAAAgPrJjGwAAAAAAAig0AAAAECNQaAAAACBGoNAAAABAjEChAQAAgBiBQgMAAAAxAoUGAAAAYoRU6I+H28url4+eRQAAAACYDEqh3+8uFncbcnOmKEouFpfM10nq7LXBPuwBAACQJIRCbx6dUTJTFCcXi8t2Mb4OVseQHQNFGgoNAADAhaXQX09Xi5uHL2pbpihKWv1r5dlYP7JaYyW/hFcFAAAACFuhdy83F4+v5KZMUfKES29ghB0o4QAAAM4WQ6FfV4vL1Tu5JVMUL32DWqYe72fXmmEbAwAAOHN0hU5ojpjNmAHgXgrNPA1gphgAAIBAVIVO8CUrbwwdOH48Joa2VXmSsB4AAEDaKAqd0ByxlqkmTo8Zh8Y0MQAAAAPoFHrzeOmaCMYURc6A+dWueryf7a/8NlPNLQcAAJAkrUKnNkdMxXjbSl05uLbwIlLRMSANAACAp1bo3cvNxe3TjtqCKToJJhfFvllrMmjGODQAAAAeqdAJzhETjRCqX8n1A6oNWdlXd6HQAAAAVPC/rQAAAIAYgUIDAAAAMQKFBgAAAGIECg0AAADECBQaAAAAiBEoNABApyqyojq2ER1VkeXl9thWAHAEzlihqyJriMkdjeVtObte7uFfnGyW17PZah3ji/GTn/Lnen49X39OWOMJdbaqyCxB/J6Jb7n4I8SPXHzLxM89HJY7xLbM4283APZA6gqteEaJ9TBeFUe/+Sc1AQo9nukVuib+zkbps5TPQgghfha0Qn/L6M+ubWw8h4ig5QA4POeg0PyNHcGtfxIKHTFQ6KlMoPVZxrXBCm1/ZVYGHwJxNDhHoNCxO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5+vTp/iMqbU2mGcmJn0sz+uXSyIzueitpRj+jSOQWvY9cvhG2hSJJQ4tjZDZ6wLJDz7pEqo4vtIBlJdNpmDZ+A/oNCemmF2wFlXvmgvOFPOw7khfhvO/cCwayyc2JMHUdjDMxMtsmxAVkHkRuFPDfWJi3Gckvw4vM9k2cNAzDNM1yuVwoFFYhXr58aZqmYRj7Jk6y9v57HnFNU2gFE7wAMiQxo3wQbZ4FiBmRYowrCkZmowe3cie0hnshAigk7MkNHP5lhIA2flM+jgp8MSOCmMHnC3nYV3oHEMdcbgm7DoB39vjfO3AOwLz3j2K2PYgwXz4K3gYKEZeeTEDPY7TbE1nM9irHyuWyZVm/3H6o6re+PPMz/9NsNm3bLpfLe5VjUfvvA8PXDlQrREyYXMkgN6Z2N4Jfn+MrUcx2O5HFbGxSvZZetCzLlNJsNq+lF8cm1eAe+w3+NStkJ4FahiDDILKYpZcfjM/Mf/LZkcCf8Zn59PKDQTgtpJcmHGKQNPwjIgiCIBz4n3MiCIIgIw+KGYIgCDLyoJghCIIgIw+KGYIgCDLy/A9yNlPVfr7C0QAAAABJRU5ErkJggg==" alt="" />

XML原型:

<?xml version="1.0" encoding="utf-8"?>

<书架>
<书>
<书名>Java高级</书名>
<作者>武陟县</作者>
<价格>200元</价格>
</书>
<书>
<书名 name="xxxxxxxxxxx">Java中级</书名>
<作者>打火机</作者>
<价格>2000元</价格>
</书>
</书架>

Java类

 package Dom4j_XMLParser;

 import java.io.File;

 import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.junit.Test; public class Demo1 { // 获取第二本书的书名
@Test
public void test1() throws Exception {
// 创建SAX读取器
SAXReader reader = new SAXReader();
// 加载文档
Document document = reader.read(new File("src/book.xml"));
// 获取根节点(书架)
Element root = document.getRootElement();
// 获取根节点下的书节点,带s返回一个数组,再取数组的第二个
Element book = (Element) root.elements("书").get(1);
// 获取树下面的书名属性
Element shuming = book.element("书名");
// 获取书名开始标签与结束标签之间的值
String value = shuming.getText();
System.out.println(value); } // 获取第二本书的书名中的属性 <书名 name="xxxxxxxxxxx">Java中级</书名>
@Test
public void test2() throws Exception {
SAXReader reader = new SAXReader();
Document document = reader.read(new File("src/book.xml"));
Element root = document.getRootElement(); Element book = (Element) root.elements("书").get(1);
Element shuming = book.element("书名"); // 第一中方法
// 获取name属性
Attribute attribute = shuming.attribute("name");
// 获取name属性的值
String attrValue = attribute.getValue();
// 获取书名开始标签与结束标签之间的值
System.out.println(attrValue); //xxxxxxxxx // 第二种方法(获取书名节点的name属性的值)
System.out.println(shuming.attributeValue("name")); //xxxxxxxx }
}