Hi
I have an .aspx web form in which I would like to output only XML, no HTML.
The datasource is a datatable that's bult on the fly based on user input
from previous .aspx page so the XML output has to be genereated in the code
behind.
I was wondering if there is an elegant way of doing this in .NET using the
..NET classes...
TIA
Steve 9 2209
From a DataSet you can call method WriteXML.. Gives a nice XML output! Maybe
you can do that directly from a datatable as well, otherwise just add the
table to a dataset and then call that method.
/Lars Netzel
"Steve Peterson" <sp*******@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... Hi
I have an .aspx web form in which I would like to output only XML, no HTML. The datasource is a datatable that's bult on the fly based on user input from previous .aspx page so the XML output has to be genereated in the code behind.
I was wondering if there is an elegant way of doing this in .NET using the .NET classes...
TIA
Steve
Hi Lars - thx for the reply.
However, doesn't the WriteXML method write to a file? What I need to do is
make the XML what the cleint recieves when the request an .aspx page. For
example when they request http://www.mydomain.com/xml.aspx the recieve just
XML instead of <html><head></head><body>...</body></html>....
Steve
"Lars Netzel" <no****@doamin.com> wrote in message
news:Oj*************@TK2MSFTNGP11.phx.gbl... From a DataSet you can call method WriteXML.. Gives a nice XML output! Maybe you can do that directly from a datatable as well, otherwise just add the table to a dataset and then call that method.
/Lars Netzel
"Steve Peterson" <sp*******@nospam.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... Hi
I have an .aspx web form in which I would like to output only XML, no HTML. The datasource is a datatable that's bult on the fly based on user input from previous .aspx page so the XML output has to be genereated in the code behind.
I was wondering if there is an elegant way of doing this in .NET using the .NET classes...
TIA
Steve
Well... don't have to write it to a file. Check out the Arguments.. there
are 8 variations.
Try a stream... that shouldn't be to hard to output as a string.
/Lars
"Steve Peterson" <sp*******@nospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... Hi Lars - thx for the reply.
However, doesn't the WriteXML method write to a file? What I need to do is make the XML what the cleint recieves when the request an .aspx page. For example when they request http://www.mydomain.com/xml.aspx the recieve just XML instead of <html><head></head><body>...</body></html>....
Steve
"Lars Netzel" <no****@doamin.com> wrote in message news:Oj*************@TK2MSFTNGP11.phx.gbl... From a DataSet you can call method WriteXML.. Gives a nice XML output! Maybe you can do that directly from a datatable as well, otherwise just add the table to a dataset and then call that method.
/Lars Netzel
"Steve Peterson" <sp*******@nospam.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... Hi
I have an .aspx web form in which I would like to output only XML, no HTML. The datasource is a datatable that's bult on the fly based on user input from previous .aspx page so the XML output has to be genereated in the code behind.
I was wondering if there is an elegant way of doing this in .NET using the .NET classes...
TIA
Steve
Well you are right, Lars - & thx again for the reply
I guess the question & really have is how to get the XML INTO the .aspx page
(without the HTML) and send it back to the client. This is where I'm stuck.
I usually write for windows, but got this ASP.NET project handed to me, so I
don't really know all the tricks of making this stuff work the .aspx way...
Steve
"Lars Netzel" <no****@doamin.com> wrote in message
news:O5**************@TK2MSFTNGP12.phx.gbl... Well... don't have to write it to a file. Check out the Arguments.. there are 8 variations.
Try a stream... that shouldn't be to hard to output as a string.
/Lars
"Steve Peterson" <sp*******@nospam.com> wrote in message news:%2****************@tk2msftngp13.phx.gbl... Hi Lars - thx for the reply.
However, doesn't the WriteXML method write to a file? What I need to do is make the XML what the cleint recieves when the request an .aspx page. For example when they request http://www.mydomain.com/xml.aspx the recieve just XML instead of <html><head></head><body>...</body></html>....
Steve
"Lars Netzel" <no****@doamin.com> wrote in message news:Oj*************@TK2MSFTNGP11.phx.gbl... From a DataSet you can call method WriteXML.. Gives a nice XML output! Maybe you can do that directly from a datatable as well, otherwise just add the table to a dataset and then call that method.
/Lars Netzel
"Steve Peterson" <sp*******@nospam.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... Hi
I have an .aspx web form in which I would like to output only XML, no HTML. The datasource is a datatable that's bult on the fly based on user input from previous .aspx page so the XML output has to be genereated in the code behind.
I was wondering if there is an elegant way of doing this in .NET using the .NET classes...
TIA
Steve
Do you want to show the XML as XML or do you need to parse it some how?
If you only need to show it as xml, you just html-encode what you get from
the XMLWriter and put it on the page!
Unless you have the option to just redirect to the xml fil itself and the
whoel thing will just by it self..
/Lars
"Steve Peterson" <sp*******@nospam.com> skrev i meddelandet
news:u$**************@TK2MSFTNGP11.phx.gbl... Well you are right, Lars - & thx again for the reply
I guess the question & really have is how to get the XML INTO the .aspx page (without the HTML) and send it back to the client. This is where I'm stuck.
I usually write for windows, but got this ASP.NET project handed to me, so I don't really know all the tricks of making this stuff work the .aspx way...
Steve
"Lars Netzel" <no****@doamin.com> wrote in message news:O5**************@TK2MSFTNGP12.phx.gbl... Well... don't have to write it to a file. Check out the Arguments.. there are 8 variations.
Try a stream... that shouldn't be to hard to output as a string.
/Lars
"Steve Peterson" <sp*******@nospam.com> wrote in message news:%2****************@tk2msftngp13.phx.gbl... Hi Lars - thx for the reply.
However, doesn't the WriteXML method write to a file? What I need to do is make the XML what the cleint recieves when the request an .aspx page. For example when they request http://www.mydomain.com/xml.aspx the recieve just XML instead of <html><head></head><body>...</body></html>....
Steve
"Lars Netzel" <no****@doamin.com> wrote in message news:Oj*************@TK2MSFTNGP11.phx.gbl... From a DataSet you can call method WriteXML.. Gives a nice XML output! Maybe you can do that directly from a datatable as well, otherwise just add the table to a dataset and then call that method.
/Lars Netzel
"Steve Peterson" <sp*******@nospam.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... > Hi > > I have an .aspx web form in which I would like to output only XML, no > HTML. The datasource is a datatable that's bult on the fly based on > user input from previous .aspx page so the XML output has to be > genereated in the code behind. > > I was wondering if there is an elegant way of doing this in .NET using > the .NET classes... > > TIA > > Steve >
Thx for your reply again, Lars
No - I don't want to html-encode it. I just want the page to contain XML
instead of HTML. Il looked at the XML writer & yes - that's what I need.
But, how to I get it into the page? Is there some control I can bind it to
or anything like that?
Steve
"Lars Netzel" <tr*****@apa.se> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl... Do you want to show the XML as XML or do you need to parse it some how?
If you only need to show it as xml, you just html-encode what you get from the XMLWriter and put it on the page!
Unless you have the option to just redirect to the xml fil itself and the whoel thing will just by it self..
/Lars
"Steve Peterson" <sp*******@nospam.com> skrev i meddelandet news:u$**************@TK2MSFTNGP11.phx.gbl... Well you are right, Lars - & thx again for the reply
I guess the question & really have is how to get the XML INTO the .aspx page (without the HTML) and send it back to the client. This is where I'm stuck.
I usually write for windows, but got this ASP.NET project handed to me, so I don't really know all the tricks of making this stuff work the .aspx way...
Steve
"Lars Netzel" <no****@doamin.com> wrote in message news:O5**************@TK2MSFTNGP12.phx.gbl... Well... don't have to write it to a file. Check out the Arguments.. there are 8 variations.
Try a stream... that shouldn't be to hard to output as a string.
/Lars
"Steve Peterson" <sp*******@nospam.com> wrote in message news:%2****************@tk2msftngp13.phx.gbl... Hi Lars - thx for the reply.
However, doesn't the WriteXML method write to a file? What I need to do is make the XML what the cleint recieves when the request an .aspx page. For example when they request http://www.mydomain.com/xml.aspx the recieve just XML instead of <html><head></head><body>...</body></html>....
Steve
"Lars Netzel" <no****@doamin.com> wrote in message news:Oj*************@TK2MSFTNGP11.phx.gbl... > From a DataSet you can call method WriteXML.. Gives a nice XML output! > Maybe you can do that directly from a datatable as well, otherwise > just add the table to a dataset and then call that method. > > /Lars Netzel > > "Steve Peterson" <sp*******@nospam.com> wrote in message > news:%2****************@TK2MSFTNGP10.phx.gbl... >> Hi >> >> I have an .aspx web form in which I would like to output only XML, no >> HTML. The datasource is a datatable that's bult on the fly based on >> user input from previous .aspx page so the XML output has to be >> genereated in the code behind. >> >> I was wondering if there is an elegant way of doing this in .NET >> using the .NET classes... >> >> TIA >> >> Steve >> > >
Hello Steve,
How about :
private void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "text/xml";
DataSet myDataSet = SomeMethodToGetADataSet();
myDataSet.WriteXml(Response.OutputStream);
Response.Flush();
Response.End();
}
--
Matt Berther http://www.mattberther.com Thx for your reply again, Lars
No - I don't want to html-encode it. I just want the page to contain XML instead of HTML. Il looked at the XML writer & yes - that's what I need. But, how to I get it into the page? Is there some control I can bind it to or anything like that?
Steve
"Lars Netzel" <tr*****@apa.se> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
Do you want to show the XML as XML or do you need to parse it some how?
If you only need to show it as xml, you just html-encode what you get from the XMLWriter and put it on the page!
Unless you have the option to just redirect to the xml fil itself and the whoel thing will just by it self..
/Lars
"Steve Peterson" <sp*******@nospam.com> skrev i meddelandet news:u$**************@TK2MSFTNGP11.phx.gbl...
Well you are right, Lars - & thx again for the reply
I guess the question & really have is how to get the XML INTO the .aspx page (without the HTML) and send it back to the client. This is where I'm stuck.
I usually write for windows, but got this ASP.NET project handed to me, so I don't really know all the tricks of making this stuff work the .aspx way...
Steve
"Lars Netzel" <no****@doamin.com> wrote in message news:O5**************@TK2MSFTNGP12.phx.gbl...
Well... don't have to write it to a file. Check out the Arguments.. there are 8 variations.
Try a stream... that shouldn't be to hard to output as a string.
/Lars
"Steve Peterson" <sp*******@nospam.com> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
> Hi Lars - thx for the reply. > > However, doesn't the WriteXML method write to a file? What I need > to do is make the XML what the cleint recieves when the request an > .aspx page. For example when they request > http://www.mydomain.com/xml.aspx the recieve just XML instead of > <html><head></head><body>...</body></html>.... > > Steve > > "Lars Netzel" <no****@doamin.com> wrote in message > news:Oj*************@TK2MSFTNGP11.phx.gbl... > >> From a DataSet you can call method WriteXML.. Gives a nice XML >> output! Maybe you can do that directly from a datatable as well, >> otherwise just add the table to a dataset and then call that >> method. >> >> /Lars Netzel >> >> "Steve Peterson" <sp*******@nospam.com> wrote in message >> news:%2****************@TK2MSFTNGP10.phx.gbl... >> >>> Hi >>> >>> I have an .aspx web form in which I would like to output only >>> XML, no HTML. The datasource is a datatable that's bult on the >>> fly based on user input from previous .aspx page so the XML >>> output has to be genereated in the code behind. >>> >>> I was wondering if there is an elegant way of doing this in .NET >>> using the .NET classes... >>> >>> TIA >>> >>> Steve >>>
Response.Clear(); // remove any html in the buffer (or aspx page)
XmlTextWriter xml = new XmlTextWriter(Response.OutputStream,null);
// now use xmlwriter to output xml
-- bruce (sqlwork.com)
"Steve Peterson" <sp*******@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
| Hi
|
| I have an .aspx web form in which I would like to output only XML, no
HTML.
| The datasource is a datatable that's bult on the fly based on user input
| from previous .aspx page so the XML output has to be genereated in the
code
| behind.
|
| I was wondering if there is an elegant way of doing this in .NET using the
| .NET classes...
|
| TIA
|
| Steve
|
|
thx matt for your reply!
I dound another solution (I can't believe I missed it before) is simply
'mydataset.GetXML'. I put one literal control in the page (I set the
ContentType="text/xml" attribute in the @Page directive & whacked all the
autogenerated HTML), then in code behind its:
...(code to get data set)
mylitcontrol.text = mydataset.GetXML
Viola!
Steve
"Matt Berther" <mb******@hotmail.com> wrote in message
news:73***********************@news.microsoft.com. .. Hello Steve,
How about:
private void Page_Load(object sender, EventArgs e) { Response.ContentType = "text/xml";
DataSet myDataSet = SomeMethodToGetADataSet(); myDataSet.WriteXml(Response.OutputStream);
Response.Flush(); Response.End(); }
-- Matt Berther http://www.mattberther.com
Thx for your reply again, Lars
No - I don't want to html-encode it. I just want the page to contain XML instead of HTML. Il looked at the XML writer & yes - that's what I need. But, how to I get it into the page? Is there some control I can bind it to or anything like that?
Steve
"Lars Netzel" <tr*****@apa.se> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
Do you want to show the XML as XML or do you need to parse it some how?
If you only need to show it as xml, you just html-encode what you get from the XMLWriter and put it on the page!
Unless you have the option to just redirect to the xml fil itself and the whoel thing will just by it self..
/Lars
"Steve Peterson" <sp*******@nospam.com> skrev i meddelandet news:u$**************@TK2MSFTNGP11.phx.gbl...
Well you are right, Lars - & thx again for the reply
I guess the question & really have is how to get the XML INTO the .aspx page (without the HTML) and send it back to the client. This is where I'm stuck.
I usually write for windows, but got this ASP.NET project handed to me, so I don't really know all the tricks of making this stuff work the .aspx way...
Steve
"Lars Netzel" <no****@doamin.com> wrote in message news:O5**************@TK2MSFTNGP12.phx.gbl...
> Well... don't have to write it to a file. Check out the > Arguments.. there are 8 variations. > > Try a stream... that shouldn't be to hard to output as a string. > > /Lars > > "Steve Peterson" <sp*******@nospam.com> wrote in message > news:%2****************@tk2msftngp13.phx.gbl... > >> Hi Lars - thx for the reply. >> >> However, doesn't the WriteXML method write to a file? What I need >> to do is make the XML what the cleint recieves when the request an >> .aspx page. For example when they request >> http://www.mydomain.com/xml.aspx the recieve just XML instead of >> <html><head></head><body>...</body></html>.... >> >> Steve >> >> "Lars Netzel" <no****@doamin.com> wrote in message >> news:Oj*************@TK2MSFTNGP11.phx.gbl... >> >>> From a DataSet you can call method WriteXML.. Gives a nice XML >>> output! Maybe you can do that directly from a datatable as well, >>> otherwise just add the table to a dataset and then call that >>> method. >>> >>> /Lars Netzel >>> >>> "Steve Peterson" <sp*******@nospam.com> wrote in message >>> news:%2****************@TK2MSFTNGP10.phx.gbl... >>> >>>> Hi >>>> >>>> I have an .aspx web form in which I would like to output only >>>> XML, no HTML. The datasource is a datatable that's bult on the >>>> fly based on user input from previous .aspx page so the XML >>>> output has to be genereated in the code behind. >>>> >>>> I was wondering if there is an elegant way of doing this in .NET >>>> using the .NET classes... >>>> >>>> TIA >>>> >>>> Steve >>>>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Hawk |
last post by:
I have a custom menu control that I am creating using C#. I am rendering
HTML from a StringBuilder in my control to add the needed JavaScript to the
HTML output. I need to have the JavaScript...
|
by: Rick Strahl [MVP] |
last post by:
I often have the need to run templates that perform the equivalent of a mail
merge as part of the processing for another page. For example, I have an
invoice display page in my admin module and...
|
by: Martin |
last post by:
Hi.
I had a very frustrating afternoon and evening but I have got it all under
control now so all of a sudden I am in a good mood. I want to share some
insights on output caching with you lot.
...
|
by: Holly |
last post by:
Hi,
I have a page (A) that allows users to enter addresses
and displays direction information and map images.
The page A calls Microsoft's mappoint web service, gets
the route info and map image....
|
by: Skeptical |
last post by:
Hello,
I am trying to embed html output into my webform but could not figure out
how to so far.
The form will execute a Perl script with some parameters, and script will
output some html...
|
by: cnys |
last post by:
We have an ASP.NET 2.0 (C#) app and we're trying to add tracing into it.
The tracing functionality within .NET is great, but when we output this to a
file, it's kind of sparse.
So, we're looking...
|
by: MatsL |
last post by:
Hi,
This is seriously driving me crazy, could anyone explain to me why
neither of these doesn't produce XHTML compliant output (it is being
called in Render() btw):
output.WriteLine("<img...
|
by: aptenodytesforsteri |
last post by:
I have an ASP.NET 2.0 application I've localized to English, French,
German, and Italian.
I used resource (.resx) files.
Most of the site is static content, easily 90% of it, so I thought...
|
by: jmr |
last post by:
Hi All,
I've found a post in google group about this problem but unfortunately,
there was no answer. Sorry to ask again but maybe the initial poster has
a fix now.
The problem we have with...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
|
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...
| |