473,796 Members | 2,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieve an XML stream from my business class

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.C lear();

Page.Response.C ontentType = "text/xml";

XmlTextWriter xr = new XmlTextWriter(P age.Response.Ou tputStream,
System.Text.Enc oding.UTF8);

//Write opening elements

xr.WriteStartDo cument();

xr.WriteStartEl ement("rss");

xr.WriteAttribu teString("versi on","2.0");

xr.WriteStartEl ement("channel" );

xr.WriteElement String("title", "Workshare Corporate Blog");

xr.WriteElement String("link", "http://www.workshare.c om/company/blog");

xr.WriteElement String("descrip tion", "Latest news from Workshare.COM") ;

xr.WriteElement String("copyrig ht", "(c) Workshare.com") ;

xr.WriteElement String("ttl","5 ");

//Write the articles

xr.WriteStartEl ement("item");

xr.WriteElement String("title", "title1");

xr.WriteElement String("descrip tion","this is title 1");

xr.WriteElement String("link"," http://www.workshare.c om");

xr.WriteElement String("pubDate ", DateTime.Now.To String());

xr.WriteEndElem ent();

xr.WriteStartEl ement("item");

xr.WriteElement String("title", "title2");

xr.WriteElement String("descrip tion","this is title 2");

xr.WriteElement String("link"," http://www.workshare.c om");

xr.WriteElement String("pubDate ", DateTime.Now.To String());

xr.WriteEndElem ent();

//Close the opening elements

xr.WriteEndElem ent();

xr.WriteEndElem ent();

xr.WriteEndDocu ment();

xr.Flush();

xr.Close();

Page.Response.E nd();

Nov 19 '05 #1
2 1318
Got it, just posting up so no one has to worry
I chagned my method to be a return type of String

Them wrote the XmlTextReader directly to a memorystream,
Then using the StreamReader, wrote the to a string.

I'm happy now :)

"Grant Merwitz" <gr***@workshar e.com> wrote in message
news:eQ******** ******@tk2msftn gp13.phx.gbl...
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.C lear();

Page.Response.C ontentType = "text/xml";

XmlTextWriter xr = new XmlTextWriter(P age.Response.Ou tputStream,
System.Text.Enc oding.UTF8);

//Write opening elements

xr.WriteStartDo cument();

xr.WriteStartEl ement("rss");

xr.WriteAttribu teString("versi on","2.0");

xr.WriteStartEl ement("channel" );

xr.WriteElement String("title", "Workshare Corporate Blog");

xr.WriteElement String("link", "http://www.workshare.c om/company/blog");

xr.WriteElement String("descrip tion", "Latest news from Workshare.COM") ;

xr.WriteElement String("copyrig ht", "(c) Workshare.com") ;

xr.WriteElement String("ttl","5 ");

//Write the articles

xr.WriteStartEl ement("item");

xr.WriteElement String("title", "title1");

xr.WriteElement String("descrip tion","this is title 1");

xr.WriteElement String("link"," http://www.workshare.c om");

xr.WriteElement String("pubDate ", DateTime.Now.To String());

xr.WriteEndElem ent();

xr.WriteStartEl ement("item");

xr.WriteElement String("title", "title2");

xr.WriteElement String("descrip tion","this is title 2");

xr.WriteElement String("link"," http://www.workshare.c om");

xr.WriteElement String("pubDate ", DateTime.Now.To String());

xr.WriteEndElem ent();

//Close the opening elements

xr.WriteEndElem ent();

xr.WriteEndElem ent();

xr.WriteEndDocu ment();

xr.Flush();

xr.Close();

Page.Response.E nd();


Nov 19 '05 #2
Got it, just posting up so no one has to worry
I chagned my method to be a return type of String

Them wrote the XmlTextReader directly to a memorystream,
Then using the StreamReader, wrote the to a string.

I'm happy now :)

"Grant Merwitz" <gr***@workshar e.com> wrote in message
news:eQ******** ******@tk2msftn gp13.phx.gbl...
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.C lear();

Page.Response.C ontentType = "text/xml";

XmlTextWriter xr = new XmlTextWriter(P age.Response.Ou tputStream,
System.Text.Enc oding.UTF8);

//Write opening elements

xr.WriteStartDo cument();

xr.WriteStartEl ement("rss");

xr.WriteAttribu teString("versi on","2.0");

xr.WriteStartEl ement("channel" );

xr.WriteElement String("title", "Workshare Corporate Blog");

xr.WriteElement String("link", "http://www.workshare.c om/company/blog");

xr.WriteElement String("descrip tion", "Latest news from Workshare.COM") ;

xr.WriteElement String("copyrig ht", "(c) Workshare.com") ;

xr.WriteElement String("ttl","5 ");

//Write the articles

xr.WriteStartEl ement("item");

xr.WriteElement String("title", "title1");

xr.WriteElement String("descrip tion","this is title 1");

xr.WriteElement String("link"," http://www.workshare.c om");

xr.WriteElement String("pubDate ", DateTime.Now.To String());

xr.WriteEndElem ent();

xr.WriteStartEl ement("item");

xr.WriteElement String("title", "title2");

xr.WriteElement String("descrip tion","this is title 2");

xr.WriteElement String("link"," http://www.workshare.c om");

xr.WriteElement String("pubDate ", DateTime.Now.To String());

xr.WriteEndElem ent();

//Close the opening elements

xr.WriteEndElem ent();

xr.WriteEndElem ent();

xr.WriteEndDocu ment();

xr.Flush();

xr.Close();

Page.Response.E nd();


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
15613
by: TJ | last post by:
I need to be able to pass a pointer to a (managed code) Stream object to a COM method so it can serialize its data into the stream. I have a C# application that makes uses of Randolf Duke's MimeSniffer COM component (http://www.codeproject.com/internet/mimesniffer.asp). My application (pop3ImageGrabber) uses MimeSniffer to identify each image attachment in emails that have been collected from a POP3 mailbox. MimeSniffer gives the...
0
1677
by: Carl Mercier | last post by:
(I'm using C# 2.0) Hi, I have placed an icon file in resources.resx. The problem is that I don't know how to retrieve it. In VB.NET 2.0, My.Resources.MyIcon does the trick, but what's the C# equivalent? Unfortunately, what happens under the hood with the My namespace is not well documented. Reflector on Microsoft.VisualBasic.dll
2
7991
by: ce | last post by:
Being a newbie regarding serialization and memorystreams, I was trying to see if i could improve page performance (avoiding going to the db on a postback) by saving my serialized business object in viewstate and getting it back from the client on a postback. But the last line of the sample code below throws a "Stream was not readable" error when i'm trying to get the serialized object back out of the viewstate and memorystream. Any...
8
10468
by: Marc Gravell | last post by:
I want to write a method that will accept a stream as a parameter, and which will write xml to the stream (based in reality on database results) using the XmlTextWriter class. However, this insists on closing my stream, and I can't convince it not to. A much-simplified example is below; basically, as soon as the writer is disposed (marked **** below) the base stream gets closed - which is a pain if I was still using it ;-p The base...
0
1280
by: r1 | last post by:
I am relatively inexperienced in using delegates and asynchronous methods. I read several articles, and then I developed my own code with a mission to improve the performance. Wow! I cannot believe the difference in speed! However, the asynch operation fails sometimes, despite of the fact that it works most of the time. I am really at a loss how to fix this sporadic and erratic behavior. This is a web application developed with...
7
13382
by: semedao | last post by:
Hi, I am using cryptostream on both sides on tcp connection that pass data. I am also use asyc socket , so , the data that recieved in the callback method not always have the length of the buffer I sent. for ex I want to send 10000 bytes I can get it in 10 times of 1000 bytes each. so , I need to know when I complete the receiving , I want to write inside cryptostream and check the position compare it to the length I already know I...
1
13272
by: ahujasatna | last post by:
Hi all!! i am working on C#, ASP.Net with Sql server2000 and i am facing a problem, my Question is: "How to insert and retrieve images to/from Sqlserver2000 Database" I created a table in database there are only two Columns:
2
4135
by: Adam Teale | last post by:
hey guys Is there a builtin/standard install method in python for retrieving or finding out an image's dimensions? A quick google found me this: http://www.pythonware.com/library/pil/handbook/introduction.htm but it looks like it is something I will need to install - I'd like to be able to pass my script around to people without them needing any
5
9447
by: =?Utf-8?B?QXhlbCBEYWhtZW4=?= | last post by:
Hi, I've created a class library assembly containing several string resource files, like: - TableColumns.resx - TableColumns.de.resx - General.resx - General.de.resx
0
10453
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10223
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10172
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.