473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Display XML file

Hello,

I am using a XSL file to transform a XML file.
Then I want to display the XML file in browser as XML type.
I am working on an Asp.Net 2.0 HTTP Generic Handler (.ashx).

My code is:

Public Sub ProcessRequest(ByVal context As HttpContext) Implements
IHttpHandler.ProcessRequest

Dim server As System.Web.HttpServerUtility =
System.Web.HttpContext.Current.Server
Dim docXml As XmlDocument = New XmlDocument
docXml.Load(server.MapPath("~/App_Data/Doc.Xml"))
Dim docXsl As XslCompiledTransform = New XslCompiledTransform
docXsl.Load(server.MapPath("~/App_Data/Doc.xsl"))
docXsl.Transform(docXml, Nothing,
HttpContext.Current.Response.Output)
' context.Response.ContentType = "text/xml"
' ??? context.Response.Write(...)

End Sub

I need to display the XML file in my browser as XML file.
With docXsl.Transform(docXml, Nothing,
HttpContext.Current.Response.Output) I am not doing it.

Is there an option to make this hapening?

Maybe if I save the result in a XML object and then place it in
context.Response.Write(...).

I think this would be the best option.

Could someone help me out?

Thanks,
Miguel

Oct 15 '06 #1
3 8828
I hope i understood ur question.
But u can just double click on the XML file
Patrick
"shapper" <md*****@gmail.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.com...
Hello,

I am using a XSL file to transform a XML file.
Then I want to display the XML file in browser as XML type.
I am working on an Asp.Net 2.0 HTTP Generic Handler (.ashx).

My code is:

Public Sub ProcessRequest(ByVal context As HttpContext) Implements
IHttpHandler.ProcessRequest

Dim server As System.Web.HttpServerUtility =
System.Web.HttpContext.Current.Server
Dim docXml As XmlDocument = New XmlDocument
docXml.Load(server.MapPath("~/App_Data/Doc.Xml"))
Dim docXsl As XslCompiledTransform = New XslCompiledTransform
docXsl.Load(server.MapPath("~/App_Data/Doc.xsl"))
docXsl.Transform(docXml, Nothing,
HttpContext.Current.Response.Output)
' context.Response.ContentType = "text/xml"
' ??? context.Response.Write(...)

End Sub

I need to display the XML file in my browser as XML file.
With docXsl.Transform(docXml, Nothing,
HttpContext.Current.Response.Output) I am not doing it.

Is there an option to make this hapening?

Maybe if I save the result in a XML object and then place it in
context.Response.Write(...).

I think this would be the best option.

Could someone help me out?

Thanks,
Miguel

Oct 16 '06 #2
This is done at runtime.
I don't want to save the result to a file
I want to display the result in the brower ... yes, like i would get if
i would open a xml file.

Thanks,
Miguel

Patrick.O.Ige wrote:
I hope i understood ur question.
But u can just double click on the XML file
Patrick
"shapper" <md*****@gmail.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.com...
Hello,

I am using a XSL file to transform a XML file.
Then I want to display the XML file in browser as XML type.
I am working on an Asp.Net 2.0 HTTP Generic Handler (.ashx).

My code is:

Public Sub ProcessRequest(ByVal context As HttpContext) Implements
IHttpHandler.ProcessRequest

Dim server As System.Web.HttpServerUtility =
System.Web.HttpContext.Current.Server
Dim docXml As XmlDocument = New XmlDocument
docXml.Load(server.MapPath("~/App_Data/Doc.Xml"))
Dim docXsl As XslCompiledTransform = New XslCompiledTransform
docXsl.Load(server.MapPath("~/App_Data/Doc.xsl"))
docXsl.Transform(docXml, Nothing,
HttpContext.Current.Response.Output)
' context.Response.ContentType = "text/xml"
' ??? context.Response.Write(...)

End Sub

I need to display the XML file in my browser as XML file.
With docXsl.Transform(docXml, Nothing,
HttpContext.Current.Response.Output) I am not doing it.

Is there an option to make this hapening?

Maybe if I save the result in a XML object and then place it in
context.Response.Write(...).

I think this would be the best option.

Could someone help me out?

Thanks,
Miguel
Oct 17 '06 #3
Hi,

shapper wrote:
This is done at runtime.
I don't want to save the result to a file
I want to display the result in the brower ... yes, like i would get if
i would open a xml file.

Thanks,
Miguel
I display dynamically generated XML content in the browser with this code:

// Set the response's content type. It must be XML!
context.Response.ContentType = "text/xml; charset=utf-8";
context.Response.StatusCode = 200;

// Save the XML document using the response's stream.
docResponse.Save(
new XmlTextWriter( context.Response.OutputStream,
context.Request.ContentEncoding ) );

where docResponse is an XmlDocument created for example like this (this
example returns the server's date/time)

XmlDocument docResponse = new XmlDocument();
XmlElement elResponse = docResponse.CreateElement( "response" );
docResponse.AppendChild( elResponse );

XmlElement elCurrent = docResponse.CreateElement( "current" );
string strDate = DateTime.Now.ToLongDateString();
string strTime = DateTime.Now.ToLongTimeString();
elCurrent.SetAttribute( "date", strDate );
elCurrent.SetAttribute( "time", strTime );
elResponse.AppendChild( elCurrent );

See
http://www.galasoft-lb.ch/mydotnet/a...006100601.aspx

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Oct 17 '06 #4

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

Similar topics

8
by: Gala Grant | last post by:
I have been searching for quite a while to find an answer (that doesn't involve buying 3rd party software) as to how to get asp.net to not display any file extension. Has anyone succeeded in doing...
5
by: Martin Moser | last post by:
Does somebody knows, if theres a way to display any file (tiff, doc, pdf, .....) "inline" on an asp.net site? What I want to do is, to display a file, which is stored in the DB, and some...
5
by: Geoff Pennington | last post by:
My VB.Net app reads an Excel file, processes it one row at a time, and when processing is complete writes the row to a database. The typical file will have several thousand rows and may take a...
1
by: Tim | last post by:
Can anyone tell me how can i use ASP to display a file in the web browser? the file is located on the server in C:\temp directory. It can be any file. Is there any way that i can do this? Thank...
1
by: shapper | last post by:
Hello, I am trying to convert an Asp.Net XML sitemap file in a Google XMl sitemap file using a XSL file using an HttpHandler. Everything seems well in my code but I am getting an error: XML...
15
by: Matt | last post by:
Is there a way to display the file selection window for a file input field via JavaScript? My goal is to emulate the behavior seen in Yahoo! Mail BETA. When adding an attachment, it displays a...
1
by: sajithamol | last post by:
can anyone help me to retrieve a particular set of files(say ".log" ) fron unix server.i need to display the file which was created before a particular date ,and also need its size and date of...
2
by: BASSPU03 | last post by:
I used the Common Dialog API to store file paths on my form's underlying table. These paths are displayed in a textbox that I can click to open the selected file. Having stored the file paths in...
2
by: radhikams | last post by:
Hi I have a html file in some location into which i do read and write operations...Now when i download that file it is getting displayed in the same browser... I want that in a different...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.