0

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?

1 Answer 1

2

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");
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.