xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 368KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-05-21
  • 語言: Java
  • 標(biāo)簽: java??xml??dtd??xsd??

資源簡(jiǎn)介

文檔中有代碼案例,詳細(xì)講解了使用java讀取xml,并附帶有關(guān)于xml的dtd講解,里面包含詳細(xì)的文檔和代碼案例。和讀取xml所需的jar。

資源截圖

代碼片段和文件信息

package?com.bzjy.test;

import?org.junit.Test;
import?org.w3c.dom.*;
import?javax.xml.parsers.*;
import?java.io.*;

public?class?JavaReadxml?{
//?Document可以看作是xml在內(nèi)存中的一個(gè)鏡像那么一旦獲取這個(gè)Document?就意味著可以通過對(duì)
//?內(nèi)存的操作來實(shí)現(xiàn)對(duì)xml的操作首先第一步獲取xml相關(guān)的Document
private?Document?doc?=?null;

public?void?init(String?xmlFile)?throws?Exception?{
//?很明顯該類是一個(gè)單例先獲取產(chǎn)生DocumentBuilder工廠
//?的工廠在通過這個(gè)工廠產(chǎn)生一個(gè)DocumentBuilder
//?DocumentBuilder就是用來產(chǎn)生Document的
DocumentBuilderFactory?dbf?=?DocumentBuilderFactory.newInstance();
DocumentBuilder?db?=?dbf.newDocumentBuilder();
//?這個(gè)Document就是一個(gè)xml文件在內(nèi)存中的鏡像
doc?=?db.parse(new?File(xmlFile));
}

//?該方法負(fù)責(zé)把xml文件的內(nèi)容顯示出來
public?void?viewxml(String?xmlFile)?throws?Exception?{
this.init(xmlFile);
//?在xml文件里只有一個(gè)根元素先把根元素拿出來看看
Element?element?=?doc.getDocumentElement();
System.out.println(“根元素為:“?+?element.getTagName());

NodeList?nodeList?=?doc.getElementsByTagName(“person“);
System.out.println(“book節(jié)點(diǎn)鏈的長(zhǎng)度:“?+?nodeList.getLength());

Node?fatherNode?=?nodeList.item(0);
System.out.println(“父節(jié)點(diǎn)為:“?+?fatherNode.getNodeName());

//?把父節(jié)點(diǎn)的屬性拿出來
NamedNodeMap?attributes?=?fatherNode.getAttributes();

for?(int?i?=?0;?i? Node?attribute?=?attributes.item(i);
System.out.println(“book的屬性名為:“?+?attribute.getNodeName()
+?“?相對(duì)應(yīng)的屬性值為:“?+?attribute.getNodeValue());
}

NodeList?childNodes?=?fatherNode.getChildNodes();
System.out.println(childNodes.getLength());
for?(int?j?=?0;?j? Node?childNode?=?childNodes.item(j);
//?如果這個(gè)節(jié)點(diǎn)屬于Element?再進(jìn)行取值
if?(childNode?instanceof?Element)?{
//?System.out.println(“子節(jié)點(diǎn)名為:“+childNode.getNodeName()+“相對(duì)應(yīng)的值為“+childNode.getFirstChild().getNodeValue());
System.out.println(“子節(jié)點(diǎn)名為:“?+?childNode.getNodeName()
+?“相對(duì)應(yīng)的值為“?+?childNode.getFirstChild().getNodeValue());
}
}

}

@Test
public?void?test_xml()?throws?Exception?{
JavaReadxml?parse?=?new?JavaReadxml();
//?我的xml文件放置在項(xiàng)目下
parse.viewxml(“person.xml“);
}
}

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

?????文件??????23969??2017-01-06?11:52??dtd-xml\DTD文件.docx

?????文件????????607??2017-01-06?10:15??dtd-xml\Read_xml\.classpath

?????文件????????297??2017-06-05?12:54??dtd-xml\Read_xml\.mymetadata

?????文件???????1535??2017-01-06?11:29??dtd-xml\Read_xml\.project

?????文件????????500??2017-01-06?10:13??dtd-xml\Read_xml\.settings\.jsdtscope

?????文件???????1009??2017-01-06?11:30??dtd-xml\Read_xml\.settings\com.genuitec.eclipse.j2eedt.core.prefs

?????文件????????364??2017-01-06?10:13??dtd-xml\Read_xml\.settings\org.eclipse.jdt.core.prefs

?????文件????????462??2017-01-06?11:30??dtd-xml\Read_xml\.settings\org.eclipse.wst.common.component

?????文件????????252??2017-01-06?10:13??dtd-xml\Read_xml\.settings\org.eclipse.wst.common.project.facet.core.xml

?????文件?????????49??2017-01-06?10:13??dtd-xml\Read_xml\.settings\org.eclipse.wst.jsdt.ui.superType.container

?????文件??????????6??2017-01-06?10:13??dtd-xml\Read_xml\.settings\org.eclipse.wst.jsdt.ui.superType.name

?????文件????????365??2017-06-05?12:55??dtd-xml\Read_xml\person.xml

?????文件????????387??2017-06-05?13:13??dtd-xml\Read_xml\pet.dtd

?????文件????????575??2017-06-05?13:13??dtd-xml\Read_xml\pet3.xml

?????文件???????2300??2017-06-05?12:56??dtd-xml\Read_xml\src\com\bzjy\test\JavaReadxml.java

?????文件????????829??2017-01-06?10:13??dtd-xml\Read_xml\WebRoot\index.jsp

?????文件?????????36??2017-01-06?10:13??dtd-xml\Read_xml\WebRoot\meta-INF\MANIFEST.MF

?????文件???????3043??2017-06-05?12:56??dtd-xml\Read_xml\WebRoot\WEB-INF\classes\com\bzjy\test\JavaReadxml.class

?????文件????????462??2017-01-06?11:29??dtd-xml\Read_xml\WebRoot\WEB-INF\web.xml

?????文件?????930816??2017-06-05?13:08??dtd-xml\TP06.ppt

?????文件??????18960??2017-01-06?11:49??dtd-xml\xml文檔.docx

?????文件???????1411??2011-02-28?16:42??dtd-xml\教學(xué)演示案例\示例10:按照規(guī)范格式保存寵物信息到HTML文檔\TestIO.java

?????文件????????420??2011-02-28?16:42??dtd-xml\教學(xué)演示案例\示例1:xhtml文件舉例\example.xhtml

?????文件????????381??2011-02-28?16:42??dtd-xml\教學(xué)演示案例\示例2:xml文件舉例\pet1.xml

?????文件????????944??2011-02-28?16:42??dtd-xml\教學(xué)演示案例\示例3:使用內(nèi)部DTD文件\pet2.xml

?????文件????????100??2011-02-28?16:42??dtd-xml\教學(xué)演示案例\示例6:使用CSS格式化xml\pet.css

?????文件???????1976??2011-02-28?16:42??dtd-xml\教學(xué)演示案例\示例7:使用DOM解析xml文件\TestDOM.java

?????文件????????865??2011-02-28?16:42??dtd-xml\教學(xué)演示案例\示例8:使用Reader讀取文件\TestIO1.java

?????文件????????674??2011-02-28?16:42??dtd-xml\教學(xué)演示案例\示例9:使用Writer寫文件\TestIO2.java

?????目錄??????????0??2018-03-15?12:50??dtd-xml\Read_xml\WebRoot\WEB-INF\classes\com\bzjy\test

............此處省略29個(gè)文件信息

評(píng)論

共有 條評(píng)論

相關(guān)資源