´ó¼ÒºÃ£¬ÎÒÎʸöDataRowת»»ÎªxmlµÄ - .NET¼¼Êõ / C#
C# code:
DataRow dr = new DataRow();//Êý¾ÝÐÐ
DataSet ds = new DataSet();
string xml = ds.GetXml();
using (System.IO.StreamWriter sw = new System.IO.StreamWriter("d:\\1.xml", false, Encoding.UTF8))
{
sw.Write(xml);
}
´ó¼ÒºÃ£¬ÎÒÓÐÒ»ÐÐÊý¾Ýdr,ÎÒÏë°ÑËûת»»ÎªÒ»¸öxmlÎļþÀ´´¦Àí¡£
DataSet ÓÐGetXml()£¬ÄÇDataRowÓÐʲô£¿
Èç¹ûÊÇ×Ô¼ºÊÖ¶¯À´Éú³É£¬×Ö¶ÎÌ«¶à£¬ÀÛËÀÁË£¡
WriteXml¡£
DataTableºÍDataSet²»ÊÇ ¶¼ÓÐô£¿
DataRowÒ»ÐÐת³ÉXML£¿
Ò»°ã¶¼ÊÇÕû¸öTableת»»XML,²»¹ýÒ»ÐÐÄãÒ²¿ÉÒÔµ±Ö»ÓÐÒ»ÐÐÊý¾ÝµÄtable
C# code:
/// ½«DataSet¶ÔÏóÊý¾Ý±£´æΪXMLÎļþ
/// </summary>
/// <param name="dt">DataSet</param>
/// <param name="xmlFilePath">XMLÎļþ·¾¶</param>
/// <returns>boolÖµ</returns>
public static bool CDataToXmlFile(DataTable dt, string xmlFilePath)
{
if ((dt != null) && (!string.IsNullOrEmpty(xmlFilePath)))
{
//string path =System.Windows.Forms.Application.StartupPath + System.Configuration.ConfigurationManager.AppSettings["flow"]+ xmlFilePath;
strin
Ïà¹ØÎÊ´ð£º
´ÓÊý¾Ý¿âÖвéѯһÕűíµÄÊý¾Ý
select ²¿ÃÅ,ÐÕÃû from tb
ÈçºÎ²ÅÄÜÉú³ÉÏÂÃæµÄxml¸ñʽ
XML code:
<folder state="unchecked" label="È«²¿">
¡¡¡¡ <folder state="unchecked&qu ......
Private Sub Command1_Click()
Dim MyString() As String
Open "a.xml" For Binary As #1 ' ´ò¿ª¸Õ´´½¨µÄÎļþ¡£
ReDim MyString(LOF(1) - 1)
Put #1, , MyRecord ' ¶ÁÈëËùÓÐ×Ö·ûµ½±äÁ¿ÖÐ ......
ÏÖÔÚÓиöxmlÎļþÊÇ<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xm ......
ΪʲôÎҵijÌÐòµ÷ÓÃXMLÅäÖÃÎļþÖеİ¢À²®ÎÄÏÔʾ²»³öÀ´£¿ÆäËûµÄÓïÖÖ¶¼¿ÉÒÔ£¬ÈçÖÐÎÄ£¬Ó¢ÎÄ£¬µÂÎĶ¼¿É¡£
ÎÒ½«XMLµÄ±àÂë¸ÄΪutf-8ºÍunicodeµÄµ½µÃ½á¹û¶¼Ò»Ñù.
°¢À²®ÎĵÄ×Ö¿âÄãÓÐô£¿
ÓÐ,ÎÒµÄEXEÊÇ·ÅÔÚpc»úÉÏÖ´Ðе ......
XMLÎļþÄÚÈÝ£º
- <ResList>
<page>0</page>
- <resItem>
<resName>WWW</resName>
</resItem>
- <resItem>
&nb ......