473,771 Members | 2,297 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Pr ocessRequest

Dim server As System.Web.Http ServerUtility =
System.Web.Http Context.Current .Server
Dim docXml As XmlDocument = New XmlDocument
docXml.Load(ser ver.MapPath("~/App_Data/Doc.Xml"))
Dim docXsl As XslCompiledTran sform = New XslCompiledTran sform
docXsl.Load(ser ver.MapPath("~/App_Data/Doc.xsl"))
docXsl.Transfor m(docXml, Nothing,
HttpContext.Cur rent.Response.O utput)
' context.Respons e.ContentType = "text/xml"
' ??? context.Respons e.Write(...)

End Sub

I need to display the XML file in my browser as XML file.
With docXsl.Transfor m(docXml, Nothing,
HttpContext.Cur rent.Response.O utput) 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.Respons e.Write(...).

I think this would be the best option.

Could someone help me out?

Thanks,
Miguel

Oct 15 '06 #1
3 8847
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******** *************@i 3g2000cwc.googl egroups.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.Pr ocessRequest

Dim server As System.Web.Http ServerUtility =
System.Web.Http Context.Current .Server
Dim docXml As XmlDocument = New XmlDocument
docXml.Load(ser ver.MapPath("~/App_Data/Doc.Xml"))
Dim docXsl As XslCompiledTran sform = New XslCompiledTran sform
docXsl.Load(ser ver.MapPath("~/App_Data/Doc.xsl"))
docXsl.Transfor m(docXml, Nothing,
HttpContext.Cur rent.Response.O utput)
' context.Respons e.ContentType = "text/xml"
' ??? context.Respons e.Write(...)

End Sub

I need to display the XML file in my browser as XML file.
With docXsl.Transfor m(docXml, Nothing,
HttpContext.Cur rent.Response.O utput) 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.Respons e.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******** *************@i 3g2000cwc.googl egroups.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.Pr ocessRequest

Dim server As System.Web.Http ServerUtility =
System.Web.Http Context.Current .Server
Dim docXml As XmlDocument = New XmlDocument
docXml.Load(ser ver.MapPath("~/App_Data/Doc.Xml"))
Dim docXsl As XslCompiledTran sform = New XslCompiledTran sform
docXsl.Load(ser ver.MapPath("~/App_Data/Doc.xsl"))
docXsl.Transfor m(docXml, Nothing,
HttpContext.Cur rent.Response.O utput)
' context.Respons e.ContentType = "text/xml"
' ??? context.Respons e.Write(...)

End Sub

I need to display the XML file in my browser as XML file.
With docXsl.Transfor m(docXml, Nothing,
HttpContext.Cur rent.Response.O utput) 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.Respons e.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.Respons e.ContentType = "text/xml; charset=utf-8";
context.Respons e.StatusCode = 200;

// Save the XML document using the response's stream.
docResponse.Sav e(
new XmlTextWriter( context.Respons e.OutputStream,
context.Request .ContentEncodin g ) );

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.Cre ateElement( "response" );
docResponse.App endChild( elResponse );

XmlElement elCurrent = docResponse.Cre ateElement( "current" );
string strDate = DateTime.Now.To LongDateString( );
string strTime = DateTime.Now.To LongTimeString( );
elCurrent.SetAt tribute( "date", strDate );
elCurrent.SetAt tribute( "time", strTime );
elResponse.Appe ndChild( 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
1542
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 this, and if so, how? Thanks, Gala Grant
5
1991
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 information around it. If you know a way, or a third party control, please let me know. tia Martin
5
3127
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 couple minutes to process. I would like to display a running count of the number of rows processed. It is easy enough to keep a counter and set the value of a textbox to the count. I expected a high-speed odometer effect, with perhaps only the...
1
1763
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 you, tim
1
2210
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 Parsing Error: not well-formed Location: http://localhost:1132/WebSite/Google Line Number 2, Column 62:<urlset
15
14435
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 file selection window when you click a custom button/icon. I saw an example of using CSS to actually position the browse button behind an image. I am hoping that isn't the only option.
1
1954
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 creation
2
4548
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 a textbox on my form, I then changed VB code in a linked module from lpstrFile to lpstrFileTitle (in Line 50 below) to get the file's title instead of the full path. Now, I'd like the file title to keep showing up in the textbox, but I obviously...
2
1105
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 window... How this can be done... Thanks
0
9619
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10102
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
10038
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
9910
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...
0
6712
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
5354
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...
1
4007
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
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.