Overblog Follow this blog
Edit post Administration Create my blog
Balavardhan Reddy Narani

Read XML Formated Data which was getting as Result from a Query

March 7 2009 , Written by Balavardhan Published on #ASP.Net

Read XML Formated Data which was getting as Result from a Query

Query to Return XML Formated Data as Result :


SELECT <<Column Name1>>,<<Column Name2>>,<<Column Name3>>... FROM << TABLENAME >>
For XML
PATH ('<<String For Path Node>>'),
ROOT('<<String For Root Node>>')



Read above Query Result in C#

Step 1 : Create object for XML Reader
XmlReader xdr;
Step 2 : Read query Information into XML Reader by Using "ExecuteXmlReader" method of SQL Command object
xdr = command.ExecuteXmlReader();
Step 3 : Use XMLDataDocument, and load XmlReader into XMLDataDocument
XmlDataDocument xml = new XmlDataDocument();
xml.Load(xdr);

step4 : Close XmlReader and Return XmlDataDocument OuterXml.
xdr.Close();
xml.OuterXml
XmlDataDocuments OuterXml in the same foramt of Xml Document Data. by Using of XmlDocument, XmlNodelist, XmlNode you can read the data
.

Share this post

Repost 0

Comment on this post