5.9×ܽá Jaxp ½âÎöxmlÎļþÁ½ÖÖ·½Ê½__TOmcat µÄÅäÖÃ
1. Jaxp ½âÎöxmlÎļþ Dom·½Ê½
<?xml version="1.0" encoding="gbk"?>
<students>
<student id="001">
<name>ÕÅÈý</name>
<age>25</age>
</student>
<student id="002">
<name>ÀîËÄ</name>
<age>23</age>
</student>
<student id="003">
<name>ÍõÎå</name>
<age>35</age>
</student>
<student id="004">
<name>ÖÜÁù</name>
<age>20</age>
</student>
</students>
1¡¢»ñÈ¡DocumentBuilder¶ÔÏó
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance
2ͨ¹ý¹¤³§»ñÈ¡documentBulider¶ÔÏó
DocumentBuilderFatory document=factory.newDocumentBulider();
3,ʹÓÃDocumentBuilder¶ÔÏóµÄ½âÎö·½·¨£¬ÓëxmlÎļþ¹ØÁª¡£»ñÈ¡¸ÃÎļþµÄ¡£doucment¶ÔÏó¡£
Document document = (Document) builder.parse(new File("stu.xml"));
---------------------------------------------------------------------------------------------------------------
2 »ñÈ¡Element£º
NodeList list=document.getDocumentElement().getElementsByTagName("student");
for(int i=0;i<list.getLength();i++)
{
Element element=(Element) list.item(i);
NodeList list2=element.getChildNodes();
Node node = list2.item(3);
System.out.println(node.getTextContent()+".."+node.getNodeName()+"..."
+node.getNodeType()+"..."+node.getNodeValue());
}
ÔÚÒÔÉϵijÌÐòÖÐ list2.item(3)»ñÈ¡µÄÊÇstuden±êǩϵÄage ±êÇ© £¬ÒòΪ¿Õ°×ÇøÓòÒ²ÊÇÕ¼ÓÐÒ»¸ö½Úµã
Èç¹û¸ÄΪ Node node = list2.item(2) ¾Í»áµÃµ½£º
&nb
Ïà¹ØÎĵµ£º
¼¼Êõ½éÉÜ
ÔÚÒ»°ãµÄJavaÏîÄ¿ÖÐ,Éú³ÉwordÎĵµµÄʱºò,ÎÒÃÇ»áʹÓõ½jacobÀ´×÷ΪÎÒÃÇÉú³ÉwordÎĵµµÄ¹¤¾ß,µ«ÊÇjacobÊÇͨ¹ýʹÓÃJNIµ÷ÓÃdllÎļþÀ´ÊµÏÖ,ÕâÑùµÄ¹¤×÷·½Ê½´øÀ´Á˼«´óµÄÐÔÄÜ¿ªÏú.ÕâÀïÎÒÃDzÉÓÃVelocity+zip+xml¿ìËÙ¹¹½¨word2007Îĵµ,ËùÒÔ˵Õâ¸ö¼¼ÊõʵÏÖÓÐÒ»¶¨µÄ¾ÖÏÞÐÔ,Éú³ÉµÄ±ØÐëÊÇword2007Îĵµ ......
¡¡¡¡DTDʵ¼ÊÉÏ¿ÉÒÔ¿´×÷Ò»¸ö»ò¶à¸öXMLÎļþµÄÄ£°å£¬ÕâЩXMLÎļþÖеÄÔªËØ¡¢ÔªËصÄÊôÐÔ¡¢ÔªËصÄÅÅÁз½Ê½/˳Ðò¡¢ÔªËØÄܹ»°üº¬µÄÄÚÈݵȣ¬¶¼±ØÐë·ûºÏDTDÖеĶ¨Òå¡£XMLÎļþÖеÄÔªËØ£¬¼´ÎÒÃÇËù´´½¨µÄ±ê¼Ç£¬ÊǸù¾ÝÎÒÃÇÓ¦ÓõÄʵ¼ÊÇé¿öÀ´´´½¨µÄ¡£ÏëÒª´´½¨Ò»·ÝÍêÕûÐԸߡ¢ÊÊÓ¦ÐÔ¹ãµÄDTDÊǷdz£À§Äѵģ¬ÒòΪ¸÷Ðи÷Òµ¶¼ÓÐËûÃÇ×Ô¼ºµÄÐÐÒµÌص㣠......
class ImportExportToExcel
{
public class ImportExportToExcel
{
private string strConn;
private System.Windows.Forms.OpenFileDialog openFileDlg = new System.Windows.Forms.OpenFileDialog();
private System.Windows.Forms.SaveFileDialog saveFi ......