0

私が使用している (XML Auto の場合、SQL サーバーからすべてのテーブル データを取得します。XSLT を使用して、サーバーから XML のスタイルを設定します。SQL サーバーから返された xml をフォルダー内の xml ファイルに保存したい (問題のあるフォルダーと xml が作成されました)ファイル)

 protected void Page_Load(object sender, EventArgs e)
{

    string strConnenction = System.Configuration.ConfigurationManager.
ConnectionStrings["Connectionstring0034"].ConnectionString;
    XmlDocument xd = new XmlDocument();
    XPathNavigator xpathnav = xd.CreateNavigator();
    using (SqlConnection conn = new SqlConnection(strConnenction))
    {
        conn.Open();
        SqlCommand command = new SqlCommand(
            "select * from Employees as products for XML AUTO, ELEMENTS", conn);
        using (XmlWriter xw = xpathnav.PrependChild())
        {
            xw.WriteStartElement("products");
            using (XmlReader xr = command.ExecuteXmlReader())
            {
                xw.WriteNode(xr, true);
            }
            xw.WriteEndElement();
        }
    }
    XmlProducts.XPathNavigator = xpathnav;


}

}

助けてくれてどうもありがとう

4

1 に答える 1

0

保存メソッドが呼び出されていません。xmlを作成しても問題ありませんが、ファイルに書き込んでいません。

xd.Save( "myxml.xml")

于 2013-03-10T02:43:11.187 に答える