- <NewDataSet>
- <Table>
<GoodsID>1</GoodsID>
<GoodsNameCN>0005</GoodsNameCN>
<STypeID>001003</STypeID>
<GoodsIMG>0005.JPG</GoodsIMG>
<ParentID>001003</ParentID>
<CNName>阿玛尼</CNName>
</Table>
- <Table>
<GoodsID>2</GoodsID>
<GoodsNameCN>0002</GoodsNameCN>
<STypeID>001003</STypeID>
<GoodsIMG>0002.JPG</GoodsIMG>
<ParentID>001003</ParentID>
<CNName>阿玛尼</CNName>
</Table>
- <Table>
<GoodsID>23</GoodsID>
<GoodsNameCN>0026</GoodsNameCN>
<STypeID>001003</STypeID>
<GoodsIMG>0026.JPG</GoodsIMG>
<ParentID>001003</ParentID>
<CNName>阿玛尼</CNName>
</Table>
- <Table>
<GoodsID>1636</GoodsID>
<GoodsNameCN>00245</GoodsNameCN>
<STypeID>001014</STypeID>
<GoodsIMG>00245.JPG</GoodsIMG>
<ParentID>001014</ParentID>
<CNName>宝丽</CNName>
</Table>
- <Table>
<GoodsID>1637</GoodsID>
<GoodsNameCN>00241</GoodsNameCN>
<STypeID>001014</STypeID>
<GoodsIMG>00241.JPG</GoodsIMG>
<ParentID>001014</ParentID>
<CNName>宝丽</CNName>
</Table>
- <Table>
<GoodsID>1638</GoodsID>
<GoodsNameCN>00244</GoodsNameCN>
<STypeID>001014</STypeID>
<GoodsIMG>00244.JPG</GoodsIMG>
<ParentID>001014</ParentID>
<CNName>宝丽</CNName>
</Table>
</NewDataSet>有两个问题,第一个是那个Table的节点是否可以根据需要生成类似Goods这样的名称,而不是Table,我的代码是这样写的
DbHelper db = new DbHelper();
System.Data.Common.DbCommand cmd = db.GetSqlStringCommond("select * from GoodsClass where len(ParentID)>3 and ImageURL<>null or ImageURL='' order by ParentID,PRI asc");
DataTable dt = db.ExecuteDataTable(cmd); DataSet ds = db.ExecuteDataSet(cmd);
string filename = Server.MapPath(@"\xml\ImageMenu.xml"); System.IO.FileStream myFileStream = new System.IO.FileStream(filename, System.IO.FileMode.Create);
System.Xml.XmlTextWriter myXmlWriter = new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
ds.WriteXml(myXmlWriter);
myXmlWriter.Close();
第二个问题是,怎么返回一个查询语句,可以检索出所有STypeID属性值为001014的Table清大侠帮忙看看
- <Table>
<GoodsID>1</GoodsID>
<GoodsNameCN>0005</GoodsNameCN>
<STypeID>001003</STypeID>
<GoodsIMG>0005.JPG</GoodsIMG>
<ParentID>001003</ParentID>
<CNName>阿玛尼</CNName>
</Table>
- <Table>
<GoodsID>2</GoodsID>
<GoodsNameCN>0002</GoodsNameCN>
<STypeID>001003</STypeID>
<GoodsIMG>0002.JPG</GoodsIMG>
<ParentID>001003</ParentID>
<CNName>阿玛尼</CNName>
</Table>
- <Table>
<GoodsID>23</GoodsID>
<GoodsNameCN>0026</GoodsNameCN>
<STypeID>001003</STypeID>
<GoodsIMG>0026.JPG</GoodsIMG>
<ParentID>001003</ParentID>
<CNName>阿玛尼</CNName>
</Table>
- <Table>
<GoodsID>1636</GoodsID>
<GoodsNameCN>00245</GoodsNameCN>
<STypeID>001014</STypeID>
<GoodsIMG>00245.JPG</GoodsIMG>
<ParentID>001014</ParentID>
<CNName>宝丽</CNName>
</Table>
- <Table>
<GoodsID>1637</GoodsID>
<GoodsNameCN>00241</GoodsNameCN>
<STypeID>001014</STypeID>
<GoodsIMG>00241.JPG</GoodsIMG>
<ParentID>001014</ParentID>
<CNName>宝丽</CNName>
</Table>
- <Table>
<GoodsID>1638</GoodsID>
<GoodsNameCN>00244</GoodsNameCN>
<STypeID>001014</STypeID>
<GoodsIMG>00244.JPG</GoodsIMG>
<ParentID>001014</ParentID>
<CNName>宝丽</CNName>
</Table>
</NewDataSet>有两个问题,第一个是那个Table的节点是否可以根据需要生成类似Goods这样的名称,而不是Table,我的代码是这样写的
DbHelper db = new DbHelper();
System.Data.Common.DbCommand cmd = db.GetSqlStringCommond("select * from GoodsClass where len(ParentID)>3 and ImageURL<>null or ImageURL='' order by ParentID,PRI asc");
DataTable dt = db.ExecuteDataTable(cmd); DataSet ds = db.ExecuteDataSet(cmd);
string filename = Server.MapPath(@"\xml\ImageMenu.xml"); System.IO.FileStream myFileStream = new System.IO.FileStream(filename, System.IO.FileMode.Create);
System.Xml.XmlTextWriter myXmlWriter = new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
ds.WriteXml(myXmlWriter);
myXmlWriter.Close();
第二个问题是,怎么返回一个查询语句,可以检索出所有STypeID属性值为001014的Table清大侠帮忙看看
DataSet ds = db.ExecuteDataSet(cmd);
ds.Tables[0].TableName = "Goods";2.
XmlDocument doc = new XmlDocument();
doc.Load(filename);
XmlNodeList list = doc.SelectNodes("//Goods[STypeID='001014']");