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
Ïà¹ØÎĵµ£º
<html>
<head>
<title>XML Demo</title>
</head>
<body>
<script language="javascript">
function window.onload()
{
var domXML=new ActiveXObject("Microsoft.xmldom");
domXML.load("aTest.xml");
var myRoot=domXML.documentElement;
var myNodes2=myRoot.child ......
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 ......
/*
Êý¾Ý¿â²éѯXML½á¹¹£¬FOR XML PATH Óï¾äµÄÓ¦ÓÃ
*/
FOR XML PATH Óï¾äµÄÓ¦ÓÃ:
CREATE TABLE TempTable(UserID int , UserName nvarchar(50));
insert into TempTable (UserID,UserName) values (1,'a')
insert into TempTable (UserID,UserName) values (2,'b')
select UserID,UserName from TempTable FOR ......
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;
namespace jiu ......
תÔØ×Ô£ºhttp://virgos.javaeye.com/blog/611146
Ò»£®Ç°ÑÔ£º
XMLÊÇ΢Èí.NetÕ½ÂÔµÄÒ»¸öÖØÒª×é³É²¿·Ö£¬¶øÇÒËü¿ÉνÊÇXML Web·þÎñµÄ»ùʯ£¬ËùÒÔÕÆÎÕ.Net¿ò¼ÜϵÄXML¼¼Êõ×ÔÈ»ÏԵ÷dz£ÖØÒªÁË¡£±¾ÎĽ«Ö¸µ¼´ó¼ÒÈçºÎÔËÓÃC#ÓïÑÔÍê³É.Net¿ò¼ÜϵÄXMLÎĵµµÄ¶Áд²Ù×÷¡£Ê×ÏÈ£¬ÎÒ»áÏò´ó¼Ò½éÉÜ.Net¿ò¼ÜÖÐÓëXMLÏà¹ØµÄÃüÃû¿Õ¼äºÍÆäÖеÄÖØÒªÀ ......