如何把XML文档转换成txt格式
发布网友
发布时间:2022-05-04 12:57
我来回答
共3个回答
热心网友
时间:2022-04-14 17:33
这是一个把数据库里的数据生成XML格式,你稍微改一下就可以用在文本文件了。
<%@ Import Namespace= "System.Data " %>
<%@ Import Namespace= "System.Data.SqlClient " %>
<html>
<head>
<script language= "C# " runat= "server ">
public DataView Source;
public DataSet ds;
public bool getSchema, getData;
public void Submit_Click(Object sender, EventArgs evt) {
if (IsPostBack) {
SqlConnection myConnection = new SqlConnection(ConnectString.Value);
SqlDataAdapter myCommand = new SqlDataAdapter(myText.Value, myConnection);
ds = new DataSet();
myCommand.Fill(ds, "表 ");
Source = new DataView(ds.Tables[0]);
getSchema = GetSchema.Checked;
getData = GetData.Checked;
MyDataGrid.DataSource=Source;
MyDataGrid.DataBind();
}
}
</script>
</head>
<body bgcolor= "ffffcc ">
<h3> <font face= "宋体 "> SQL 到 XML 生成器 </font> </h3>
<form runat= "server ">
<table border=0 cellpadding=5 style= "font:10.5pt 宋体 ">
<tr>
<td colspan= "2 ">
<b> 连接字符串: </b> <br>
<input id= "ConnectString " type= "text " value= "server=(local);database=pubs;uid=sa;pwd=1234 " size= "85 " runat= "server ">
</td>
</tr>
<tr>
<td colspan= "2 ">
<b> 查询: </b> <br>
<input id= "myText " type= "text " value= "SELECT * FROM Authors " size= "85 " runat= "server ">
</td>
</tr>
<tr>
<td>
<input type= "radio " id= "GetSchema " name= "Mode " runat= "server "/> 获取 XML 架构 <br>
<input type= "radio " id= "GetData " name= "Mode " runat= "server "/> 获取 XML 数据 <br>
<input type= "radio " id= "GetBoth " name= "Mode " checked runat= "server "/> 两者都获取
</td>
<td valign= "top ">
<input type= "submit " runat= "server " OnServerClick= "Submit_Click ">
</td>
</tr>
<tr>
<td colspan= "2 ">
<% if (Page.IsPostBack) { %>
<b> 结果: </b> <br>
<textarea cols=80 rows=25>
<%
if (getSchema)
ds.WriteXmlSchema(Response.Output);
else if (getData)
ds.WriteXml(Response.Output, XmlWriteMode.IgnoreSchema);
else
ds.WriteXml(Response.Output, XmlWriteMode.WriteSchema);
%>
</textarea>
<% } %>
</td>
</tr>
<tr>
<td colspan= "2 ">
<% if (Page.IsPostBack) { %>
<b> 数据: </b> <br>
<% } %>
<ASP:DataGrid id= "MyDataGrid "
BackColor= "#EDBE7B "
BorderColor= "black "
ShowFooter= "false "
CellPadding=3
CellSpacing= "0 "
Font-Name= "宋体 "
Font-Size= "8pt "
HeaderStyle-BackColor= "#DC6035 "
EnableViewState= "false "
runat= "server "
/>
</td>
<tr>
</table>
</form>
</body>
</html>追问具体操作步骤
追答这就是个界面呀。你运用的是什么工具。
热心网友
时间:2022-04-14 18:51
1、文件夹选项里勾掉隐藏已知文件类型的扩展名,然后直接改后缀;
2、如果不行,就用比特玲转换器
热心网友
时间:2022-04-14 20:26
发过来我试试。garnett4321@126.com追问加QQ,我传给你 420860961 问题答案 吴金灵