I have a stored procedure that creates an XML document. I then have the following code:
using (SqlConnection con = new SqlConnection(_connectionString))
{
con.Open();
using (SqlCommand cmd = new SqlCommand("GetModuleInstallerManifestXML", con))
{
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@mod_name", SqlDbType.VarChar, 250)).Value = this.ModuleName;
using (SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
{
while (reader.Read())
{
manifestXmlList.Add(reader[]);
}
}
}
}
I need to add the xml data row by row into a list and then write that list to a file, how do I do this?
check this answer https://stackoverflow.com/a/5424250/5358389
string xmlString = string.Empty;
using (XmlReader reader = cmd.ExecuteXmlReader())
{
XDocument xml = XDocument.Load(reader);
x.Save("filePath");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.