473,757 Members | 10,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't display file in Browser. Need help please! Thank you.

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
xmlns="http://www.google.com/schemas/sitemap/0.84" />

I tried to display it as Text instead of Text/XML. I don't get the same
error. I just get a bunch of squares after the line:

Line Number 2, Column 62:<urlset
xmlns="http://www.google.com/schemas/sitemap/0.84" />

Could somebody help me out? I tried everything I could think of for the
past 2 days.

I post my entire code in this post.

Thanks,

Miguel

--------- HttpHandler --------

Public Class SiteMap : Implements IHttpHandler

' -- [Methods] -------------------------------------------

' Define handler process request
Public Sub ProcessRequest( ByVal context As HttpContext) Implements
IHttpHandler.Pr ocessRequest

' Create ASP.NET web site map
Dim webSiteMap As XmlDocument = New XmlDocument

' Load ASP.NET's site map

webSiteMap.Load (HttpContext.Cu rrent.Server.Ma pPath(Configura tionManager.App Settings("~/Web.sitemap"))

' Create google xsl document
Dim googleXsl As XslCompiledTran sform = New XslCompiledTran sform

' Load google xml document

googleXsl.Load( HttpContext.Cur rent.Server.Map Path("~/SiteMap.xsl"))

' Create xsl arguments list
Dim googleXslArgume nts As XsltArgumentLis t = New XsltArgumentLis t
googleXslArgume nts.AddParam("D omain", "",
"http://www.domain.com" )

' Create the ASP.NET's site map memory stream
Dim webSiteMapStrea m As MemoryStream = New MemoryStream

' Transform Asp.Net's site map to Google's site map and add it to
stream
googleXsl.Trans form(webSiteMap , googleXslArgume nts,
webSiteMapStrea m)

' Output Google sitemap
context.Respons e.Clear()
context.Respons e.ContentType = "text/xml; charset=utf-8"

context.Respons e.Write(Encodin g.UTF8.GetStrin g(webSiteMapStr eam.GetBuffer))
context.Respons e.End()

End Sub

' Define is handler is reusable
Public ReadOnly Property IsReusable() As Boolean Implements
IHttpHandler.Is Reusable
Get
Return False
End Get
End Property

End Class

--------- XSL --------

<?xml version="1.0" encoding="utf-8"?>
<xsl:styleshe et
version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns="http://www.google.com/schemas/sitemap/0.84"
xmlns:dk="http://schemas.microso ft.com/AspNet/SiteMap-File-1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
<xsl:param name="By27.WebS ite.Url"/>
<xsl:template match="dk:*"/>
<xsl:template match="@*|text( )|comment()"/>
<xsl:template match="/">
<xsl:element name="urlset">
<xsl:apply-templates select="//dk:siteMapNode[@google='true']"/>
</xsl:element>
</xsl:template>
<xsl:template match="dk:siteM apNode">
<xsl:element name="url">
<xsl:element name="loc">
<xsl:value-of select="$Domain " />
<xsl:value-of select="substri ng(@url, 3)"/>
</xsl:element>
<xsl:element name="lastmod">
<xsl:value-of select="@lastmo d"/>
</xsl:element>
<xsl:element name="changefre q">
<xsl:value-of select="@change freq"/>
</xsl:element>
<xsl:element name="priority" >
<xsl:value-of select="@priori ty"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

Nov 13 '06 #1
1 2208
Please, could someone help me out?
I have been trying to solve this for days.
I am never able to see the XML file in the browser.

Thanks,
Miguel

shapper wrote:
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
xmlns="http://www.google.com/schemas/sitemap/0.84" />

I tried to display it as Text instead of Text/XML. I don't get the same
error. I just get a bunch of squares after the line:

Line Number 2, Column 62:<urlset
xmlns="http://www.google.com/schemas/sitemap/0.84" />

Could somebody help me out? I tried everything I could think of for the
past 2 days.

I post my entire code in this post.

Thanks,

Miguel

--------- HttpHandler --------

Public Class SiteMap : Implements IHttpHandler

' -- [Methods] -------------------------------------------

' Define handler process request
Public Sub ProcessRequest( ByVal context As HttpContext) Implements
IHttpHandler.Pr ocessRequest

' Create ASP.NET web site map
Dim webSiteMap As XmlDocument = New XmlDocument

' Load ASP.NET's site map

webSiteMap.Load (HttpContext.Cu rrent.Server.Ma pPath(Configura tionManager.App Settings("~/Web.sitemap"))

' Create google xsl document
Dim googleXsl As XslCompiledTran sform = New XslCompiledTran sform

' Load google xml document

googleXsl.Load( HttpContext.Cur rent.Server.Map Path("~/SiteMap.xsl"))

' Create xsl arguments list
Dim googleXslArgume nts As XsltArgumentLis t = New XsltArgumentLis t
googleXslArgume nts.AddParam("D omain", "",
"http://www.domain.com" )

' Create the ASP.NET's site map memory stream
Dim webSiteMapStrea m As MemoryStream = New MemoryStream

' Transform Asp.Net's site map to Google's site map and add it to
stream
googleXsl.Trans form(webSiteMap , googleXslArgume nts,
webSiteMapStrea m)

' Output Google sitemap
context.Respons e.Clear()
context.Respons e.ContentType = "text/xml; charset=utf-8"

context.Respons e.Write(Encodin g.UTF8.GetStrin g(webSiteMapStr eam.GetBuffer))
context.Respons e.End()

End Sub

' Define is handler is reusable
Public ReadOnly Property IsReusable() As Boolean Implements
IHttpHandler.Is Reusable
Get
Return False
End Get
End Property

End Class

--------- XSL --------

<?xml version="1.0" encoding="utf-8"?>
<xsl:styleshe et
version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns="http://www.google.com/schemas/sitemap/0.84"
xmlns:dk="http://schemas.microso ft.com/AspNet/SiteMap-File-1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
<xsl:param name="By27.WebS ite.Url"/>
<xsl:template match="dk:*"/>
<xsl:template match="@*|text( )|comment()"/>
<xsl:template match="/">
<xsl:element name="urlset">
<xsl:apply-templates select="//dk:siteMapNode[@google='true']"/>
</xsl:element>
</xsl:template>
<xsl:template match="dk:siteM apNode">
<xsl:element name="url">
<xsl:element name="loc">
<xsl:value-of select="$Domain " />
<xsl:value-of select="substri ng(@url, 3)"/>
</xsl:element>
<xsl:element name="lastmod">
<xsl:value-of select="@lastmo d"/>
</xsl:element>
<xsl:element name="changefre q">
<xsl:value-of select="@change freq"/>
</xsl:element>
<xsl:element name="priority" >
<xsl:value-of select="@priori ty"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Nov 14 '06 #2

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

Similar topics

9
9376
by: Ian Richardson | last post by:
If I follow the steps on http://www.dhtmlcentral.com/tutorials/tutorials.asp?id=11 to add .js files to a document on demand, let's say by <body onload="blah();">, how can I reliably tell that it has been loaded? BTW, I'm doing this for several .js files (and I don't always know how many I'll be loading), so I need to check them all. If I code for IE, I can check all the document.scripts.readyState values (not being "uninitialized" or...
7
2861
by: Yongsub Eric Shin | last post by:
Hi. I'm just a beginner in ASP.Net. I started writing codes and I keep on getting this Runtime Error page, where it says "Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
1
9422
by: chazmanian | last post by:
We have a situation where we display PDF files through IE via a method in our code-behind as follows protected void displayPDF(string exePath, string filePath { // exePath is the Request.CurrentExecutionPath and we trim off the actual ASPX page designation an // replace that with the "filePath" which represents the path and PDF that we want to display string fullPath = exePath.Substring(0, exePath.LastIndexOf('/')) fullPath += filePath...
9
3348
by: WRH | last post by:
Hello I am new to asp but I made some Jscript functions which work fine. The functions contain some strings used as a registration key for some apps. It is important that these strings not be visible to a client using a browser. My question is...can a knowledgeable browser user view Jscript source code in an asp file?
15
2835
by: David Thielen | last post by:
Hi; My ASP.NET app (C# calling J# under .net 2.0) creates a png file in a subdirectory to display as part of the created page. However, the bitmap will not display due to a security violation. Everything is the default settings I believe. IIS is running under Local System. In IIS the DefaultAppPool is running under Network Service. Annonymous access uses the account IUSR_JASMINE (machine name is Jasmine).
3
8847
by: shapper | last post by:
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
4
388
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How can I access the client-side filesystem? ----------------------------------------------------------------------- Security means that by default you can't. In a more restricted enviroment, there are options. For example, using LiveConnect to connect to Java with Netscape, and using the FileSystemObject in IE. Check http://groups.google.com/
1
2984
by: pkamil83 | last post by:
Hello I've got a table on SQL Server 2005 with columns: ID int Text XML Image varbinary(max) In this table I'm having SVG images. All I have to do is to display those images on ASP.NET 2 web site (C#),
11
3193
by: nickyeng | last post by:
I have a html file contains a form asking user to select a choice and press enter to pass the data to server. In server there, i have a cgi script(C language) that accepts the input from browser and then output a html page to browser. The browser should open the page, but it didn't, instead, it prompt me to save the file(.cgi file i requested in form method).... how that happens? i want to display the html file that the script output...
24
1926
by: Adam | last post by:
Hi, Does anyone know of an online C-to-HTML converter to display code nicely formatted in a browser? Thanks a lot, Adam
0
9489
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
10072
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...
1
9885
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
9737
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
7286
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
6562
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
5172
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
3829
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
2698
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.