【问题标题】:displaying XML to html after retrieving from SQL 2014 XML column [closed]从 SQL 2014 XML 列检索后将 XML 显示为 html [关闭]
【发布时间】:2015-11-26 06:49:54
【问题描述】:

使用 C#,需要代码 sn-p 来查询包含 xml 数据的列并将数据写入外部 XML 文件。 之后设置 xml 文件的样式并将其显示在 html div 标签中。

【问题讨论】:

  • 我对帖子进行了评论

标签: c# sql xml


【解决方案1】:

代码看起来类似于下面的代码。您需要根据需要修改连接字符串和SQL。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace ConsoleApplication58
{
    class Program
    {
        static void Main(string[] args)
        {
            string connStr = "Enter Your Conneciton String Here";
            string SQL = "Select XML_COL_NAME from table1";
            SqlDataAdapter adapter = new SqlDataAdapter(SQL, connStr);

            DataTable dt = new DataTable();
            adapter.Fill(dt);
            dt.WriteXml("filename");
        }
    }
}

【讨论】:

  • jdweng,我刚刚注意到在检索数据时发生了一些事情。标签全部更改为 <和>围绕标记的信息,并在将其正常存储时与其标签一起存储,有什么想法可以改变这个吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-21
  • 2020-02-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多