为什么我用asp.net生成的XML文件是一行过的?没有像其它那样分层的?
我生成的是这样的:
2008060806风神
2008050805娜基莉
查看源代码如下:(源代码一行过,没有份层的)
<?xml version="1.0" encoding="gb2312"?><NewDataSet><Table><Serial>200806</Serial><Number>0806</Number><Ename>风神 </Ename></Table><Table><Serial>200805</Serial><Number>0805</Number><Ename>娜基莉 </Ename></Table></NewDataSet>
别人的是这样的:
<?xml version="1.0" encoding="utf-8" ?>
- <NewDataSet>
- <Table>
<Serial>200806</Serial>
<Name>风神</Name>
<Ename>FENGSHEN</Ename>
</Table>
- <Table>
<Serial>200805</Serial>
<Name>娜基莉</Name>
<Ename>NAKRI</Ename>
</Table>
</NewDataSet>
我的aspx文件如下:
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Xml" %>
<Script Runat="server">
Sub Page_Load
Dim conNorthwind As SqlConnection
Dim dadProducts As SqlDataAdapter
Dim dstProducts As DataSet
conNorthwind = new sqlconnection("server=192.168.10.1;UID=sa;PWD=888999;Database=typhoon")
dadproducts=new sqldataadapter("SELECT Serial, Number, Ename FROM TyphoonNew",connorthwind)
dstproducts=new dataset()
dadproducts.fill(dstproducts,"Table")
xmlproducts.document=new xmldatadocument(dstproducts)
end sub
</script>
<asp:xml id="xmlproducts" runat=server />
帮忙解决啊!!!!!
------解决方案--------------------up
------解决方案--------------------这样生成本来就没有格式的。
除非自己去遍历DataSet,然后没个DataTable加换行符,每个DataRow加换行符。
------解决方案--------------------参考一下:
http://topic.csdn.net/u/20080508/17/2950bbde-91ff-4da6-8a6b-bf41768e6377.html