我將數據從sql導出到xml,但我遇到了xml格式的問題。我現在這樣的輸出:將sql數據導出到xml
<?xml version="1.0" standalone="yes"?>
<ITEMS>
<ITEM>
<CATALOG_NUMBER>1047</CATALOG_NUMBER>
<ITEM_NAME>Adrian3 Navy Grey Red </ITEM_NAME>
<UNIT>KUS </UNIT>
<COUNTRY>CZ </COUNTRY>
<CURRENCY>CZK</CURRENCY>
<PRICE_VAT>797.00</PRICE_VAT>
<PRICE_VAT1>21.0</PRICE_VAT1>
<NOTE>Sportovní bota v barvě...
</NOTE>
</ITEM>
<ITEM>
<CATALOG_NUMBER>106</CATALOG_NUMBER>
<ITEM_NAME>Betty Hot pink</ITEM_NAME>
<UNIT>KUS </UNIT>
<COUNTRY>CZ </COUNTRY>
<CURRENCY>CZK</CURRENCY>
<PRICE_VAT>797.00</PRICE_VAT>
<PRICE_VAT1>21.0</PRICE_VAT1>
<NOTE>Krásná a jednoducháým...
</NOTE>
</ITEM>
<ITEM_GROUPS>
<GROUP>00010000000000000000</GROUP>
<GROUP_NAME>Pediped</GROUP_NAME>
</ITEM_GROUPS>
<ITEM_GROUPS>
<GROUP>00010001000000000000</GROUP>
<GROUP_NAME>Original</GROUP_NAME>
</ITEM_GROUPS>
<ITEM_GROUPS>
<GROUP>00010002000000000000</GROUP>
<GROUP_NAME>Gripngo</GROUP_NAME>
</ITEM_GROUPS>
</ITEMS>
但我需要這種格式:
<ITEMS>
<ITEM>
<CATALOG_NUMBER>1047</CATALOG_NUMBER>
<ITEM_NAME>Adrian3 Navy Grey Red </ITEM_NAME>
<UNIT>KUS </UNIT>
<COUNTRY>CZ </COUNTRY>
<CURRENCY>CZK</CURRENCY>
<PRICE_VAT>797.00</PRICE_VAT>
<PRICE_VAT1>21.0</PRICE_VAT1>
<NOTE>Sportovní bota v barvě...
</NOTE>
</ITEM>
<ITEM>
<CATALOG_NUMBER>106</CATALOG_NUMBER>
<ITEM_NAME>Betty Hot pink</ITEM_NAME>
<UNIT>KUS </UNIT>
<COUNTRY>CZ </COUNTRY>
<CURRENCY>CZK</CURRENCY>
<PRICE_VAT>797.00</PRICE_VAT>
<PRICE_VAT1>21.0</PRICE_VAT1>
<NOTE>Krásná a jednoducháým...
</NOTE>
</ITEM>
<ITEM_GROUPS>
<GROUP>00010000000000000000</GROUP>
<GROUP_NAME>Pediped</GROUP_NAME>
<GROUP>00010001000000000000</GROUP>
<GROUP_NAME>Original</GROUP_NAME>
<GROUP>00010002000000000000</GROUP>
<GROUP_NAME>Gripngo</GROUP_NAME>
</ITEM_GROUPS>
</ITEMS>
我想在XML我想有一次和第二部分。而截至XML我沒有的....
這是我的代碼:
SqlConnection con = new SqlConnection("Data Source=****");
string strSQL = "select top 3 D.KOD_ZBOZI AS CATALOG_NUMBER.....";
string strSQL2 = "select [OBCH_......";
SqlDataAdapter dt = new SqlDataAdapter(strSQL, con);
SqlDataAdapter dt2 = new SqlDataAdapter(strSQL2, con);
DataSet ds = new DataSet("ITEMS");
dt.Fill(ds, "ITEM");
dt2.Fill(ds, "ITEM_GROUPS");
ds.WriteXml(("C:\\Users\\Lukas\\Desktop\\NOHEL.xml"));
任何想法嗎?
會[XSLT](http://stackoverflow.com/questions/34093/how-to-apply-an -xslt-stylesheet-in-c-sharp)轉換是你的一個選擇嗎? –