M
Martin
Hi,
I am retriving data from sql server using the xml raw clause and an
xmltextwriter.
this is working out fine except the xml raw clause does not put a root node
on the xml that is returned from sql server and subsequently an xmldocument
can't be created from the xmltextwriter as there is no root element.
however if the xml raw query returns only a single row then there is a root
element and everything works just fine.
my question is how do I attach a root element to an xmltextwriter.
many thanks in advance.
cheers
martin.
SqlConnection conn = new SqlConnection(
"server=.;uid=pubsUser;password=pubsUser;database=pubs");
SqlCommand cmd = new SqlCommand(
"select top 1 * from authors for xml raw", //<==== does not work
when "top 1" is removed as there is no root node
conn);
conn.Open();
XmlTextReader rdr;
rdr = (XmlTextReader)cmd.ExecuteXmlReader();
XmlDocument xml = new XmlDocument();
xml.Load(rdr); <======================will fail if there is not a root
node...
xml.Save(Console.Out);
I am retriving data from sql server using the xml raw clause and an
xmltextwriter.
this is working out fine except the xml raw clause does not put a root node
on the xml that is returned from sql server and subsequently an xmldocument
can't be created from the xmltextwriter as there is no root element.
however if the xml raw query returns only a single row then there is a root
element and everything works just fine.
my question is how do I attach a root element to an xmltextwriter.
many thanks in advance.
cheers
martin.
SqlConnection conn = new SqlConnection(
"server=.;uid=pubsUser;password=pubsUser;database=pubs");
SqlCommand cmd = new SqlCommand(
"select top 1 * from authors for xml raw", //<==== does not work
when "top 1" is removed as there is no root node
conn);
conn.Open();
XmlTextReader rdr;
rdr = (XmlTextReader)cmd.ExecuteXmlReader();
XmlDocument xml = new XmlDocument();
xml.Load(rdr); <======================will fail if there is not a root
node...
xml.Save(Console.Out);