Error: This document already has a 'DocumentElement' node

S

santel

Hi,

I tried the below code to convert the sql table to xmlDocument. But it
is giving error in doc.Load(reader) Could anyone please help me out.


conn.Open();

string sql = "select ProductId, ProductName from Products FOR
XML AUTO";

SqlCommand comm = new SqlCommand(sql, conn);

XmlReader reader = comm.ExecuteXmlReader();

XmlDocument doc = new XmlDocument() ;

doc.Load(reader);

reader.Close();
conn.Close();

return doc;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top