C#²éѯÊý¾Ý¿â°Ñ½á¹ûÊä³öµ½XMLµÄÀý×Ó
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
//sqlserverÉí·ÝÑéÖ¤
//string sqlconn = "server=(local);database=keede1228;user id=sa;password=123;";
//windowsÉí·ÝÑéÖ¤
string sqlconn = "server=(local);database=keede1228;integrated security=SSPI;";
string select = "dirr4";
SqlConnection conn = new SqlConnection(sqlconn);
Console.WriteLine("33");
conn.Open();
Console.WriteLine("11");
//SqlCommand cmd = new SqlCommand(select, conn);
//SqlDataReader reader = cmd.ExecuteReader();
//while (reader.Read())
//{
// Console.WriteLine("cityid:{0} city:{1} area:{2}", reader[0], reader[1], reader[2]);
//}
SqlDataAdapter da = new SqlDataAdapter(select, conn);
DataSet ds = new DataSet();
da.Fill(ds, "custo");
foreach (DataRow row in ds.Tables["custo"].Rows)
Console.WriteLine("'{0}'from {1}", row[0], row[1]);
ds.WriteXml("write.xml", XmlWriteMode.WriteSchema);
conn.Close();
Console.WriteLine("22");
Console.ReadKey();
}
}
}
DataSetÀà̫ǿ´óÁË£¡
Ïà¹ØÎĵµ£º
//´ò¿ªÄ³Îļþ(¼ÙÉèweb.configÔÚ¸ùĿ¼ÖÐ)
string filename=Server.MapPath("/") + @"WebApplication1\web.config";
XmlDocument xmldoc= new XmlDocument();
xmldoc.Load(filename);
//µÃµ½¶¥²ã½ÚµãÁбí
......
ǰÑÔ
XMLÔ½À´Ô½ÈÈ£¬¹ØÓÚXMLµÄ»ù´¡½Ì³ÌÍøÂçÉ ......
package cn.com.xml.vo;
public class RosterVo {
private String id; //ѧºÅ
private String name; //ѧÉúÐÕÃû
private String age; //ÄêÁä
private String skill; //¿ÆÄ¿ ......
ÓÐʱºòÎÒÃÅÐèÒª°ÑEXCEL±í¸ñÖеÄÊý¾Ýת»»³ÉXML¸ñʽ ÕâÐèÒªÓõ½JXL(·ÖÎöEXCEL)°üºÍJDOM°ü(¹¹³ÉXML)
import java.io.*;
import jxl.*;
import org.jdom.Element;
import org.jdom.Document;
import org.jdom.output.XMLOutputter;
/**
*
* @author guo
*/
public class EtoX {
  ......
ÎÒÊÇʹÓõÄCMarkupÀà¶ÔXML½øÐвÙ×÷¡£
CMarkupºÃÏó¶¼ÊÇÏÈ´ÓÒ»¸öxmlÎļþÀïÃæ°ÑÄÚÈݶÁ³öÀ´£¬ÔÙ½øÐнâÎö£¬¸ãµÃÎÒºÞ²»µÃÒª°ÑÎÒµÄCStringдµ½xmlÎļþÀïÃæÔÙÈ¡³öÀ´ÁË¡£
  ......