G
Grant Merwitz
I am trying to write an XML file from my database.
Currently, i have this code on an ASPX page, but have also built a business
layer that manages all the DataRetrieval and is reference in my main ASP.NET
project.
I would like to retrieve either a stream/XmlTextWriter from the Business
layer, that i can just retrieve and write from the front end,
Whats the best method to do this?
Any advice would be greatly appreciated
Currenlty, i am writing the code directly on the page as follows:
(obviously bogus data here, as i'm just getting it to work before i use real
data - also, this is in a control, hence Page.Response)
Page.Response.Clear();
Page.Response.ContentType = "text/xml";
XmlTextWriter xr = new XmlTextWriter(Page.Response.OutputStream,
System.Text.Encoding.UTF8);
//Write opening elements
xr.WriteStartDocument();
xr.WriteStartElement("rss");
xr.WriteAttributeString("version","2.0");
xr.WriteStartElement("channel");
xr.WriteElementString("title", "Workshare Corporate Blog");
xr.WriteElementString("link", "http://www.workshare.com/company/blog");
xr.WriteElementString("description", "Latest news from Workshare.COM");
xr.WriteElementString("copyright", "(c) Workshare.com");
xr.WriteElementString("ttl","5");
//Write the articles
xr.WriteStartElement("item");
xr.WriteElementString("title","title1");
xr.WriteElementString("description","this is title 1");
xr.WriteElementString("link","http://www.workshare.com");
xr.WriteElementString("pubDate", DateTime.Now.ToString());
xr.WriteEndElement();
xr.WriteStartElement("item");
xr.WriteElementString("title","title2");
xr.WriteElementString("description","this is title 2");
xr.WriteElementString("link","http://www.workshare.com");
xr.WriteElementString("pubDate", DateTime.Now.ToString());
xr.WriteEndElement();
//Close the opening elements
xr.WriteEndElement();
xr.WriteEndElement();
xr.WriteEndDocument();
xr.Flush();
xr.Close();
Page.Response.End();
Currently, i have this code on an ASPX page, but have also built a business
layer that manages all the DataRetrieval and is reference in my main ASP.NET
project.
I would like to retrieve either a stream/XmlTextWriter from the Business
layer, that i can just retrieve and write from the front end,
Whats the best method to do this?
Any advice would be greatly appreciated
Currenlty, i am writing the code directly on the page as follows:
(obviously bogus data here, as i'm just getting it to work before i use real
data - also, this is in a control, hence Page.Response)
Page.Response.Clear();
Page.Response.ContentType = "text/xml";
XmlTextWriter xr = new XmlTextWriter(Page.Response.OutputStream,
System.Text.Encoding.UTF8);
//Write opening elements
xr.WriteStartDocument();
xr.WriteStartElement("rss");
xr.WriteAttributeString("version","2.0");
xr.WriteStartElement("channel");
xr.WriteElementString("title", "Workshare Corporate Blog");
xr.WriteElementString("link", "http://www.workshare.com/company/blog");
xr.WriteElementString("description", "Latest news from Workshare.COM");
xr.WriteElementString("copyright", "(c) Workshare.com");
xr.WriteElementString("ttl","5");
//Write the articles
xr.WriteStartElement("item");
xr.WriteElementString("title","title1");
xr.WriteElementString("description","this is title 1");
xr.WriteElementString("link","http://www.workshare.com");
xr.WriteElementString("pubDate", DateTime.Now.ToString());
xr.WriteEndElement();
xr.WriteStartElement("item");
xr.WriteElementString("title","title2");
xr.WriteElementString("description","this is title 2");
xr.WriteElementString("link","http://www.workshare.com");
xr.WriteElementString("pubDate", DateTime.Now.ToString());
xr.WriteEndElement();
//Close the opening elements
xr.WriteEndElement();
xr.WriteEndElement();
xr.WriteEndDocument();
xr.Flush();
xr.Close();
Page.Response.End();