Welcome to WebmasterWorld Guest from 34.238.189.171

Forum Moderators: ocean10000

Message Too Old, No Replies

ASP whitespace before XML declaration!

     
3:43 am on Dec 20, 2007 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member jab_creations is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 26, 2004
posts: 3178
votes: 22


I'm trying to parallel my understanding of ASP by learning what I already know in PHP. I design using XHTML 1.1 served as application/xhtml+xml (and in PHP handle media type issues (basically IE)). But right now I'm just working in the text editor with Firefox just to get this working in anything to begin with. So the issue right now is ASP is generating whitespace from the line break. When I remove the line break and put the XML declaration on the same line as ASP's VB code the page renders fine. How can I prevent ASP from adding whitespace from a line break? PHP doesn't create whitespace from this sort of formating of the syntax.

- John

Works without creating whitespace but *BAD* syntax formating practice!

<% Response.ContentType = "application/xml"%><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>JAB Creations</title>
</head>

<body>

<!--#include file="header.html"-->
<p>content here</p>

<!--#include file="footer.html"-->
</body>
</html>

Broken by adding whitespace but *GOOD* syntax formating practice!

<% Response.ContentType = "application/xml"%>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>JAB Creations</title>
</head>

<body>

<!--#include file="header.html"-->
<p>content here</p>

<!--#include file="footer.html"-->
</body>
</html>

10:13 pm on Dec 20, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 13, 2005
posts:1078
votes: 0


Hey JAB, the ASP in a page is executed before any of the HTML is ever read, so it doesn't matter where you put <% Response.ContentType = "application/xml"%> so long as it's above any other "Response." calls. You could put it between the <head> tags as is common with ASP.NET.

Chip-

9:51 am on Dec 21, 2007 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member jab_creations is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 26, 2004
posts: 3178
votes: 22


How odd, but thanks! Since it creates a line break I'm just going to do this...

</head>
<!--#include virtual="themes/header.asp"-->
<body>

- John

4:17 pm on Dec 21, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 13, 2005
posts:1078
votes: 0


One other suggestion I would make, when using includes, use virtual instead of file. Then just start every path with / (<!--#include virtual="/includes/header.html"-->)

It will make adding sub directories to the website a lot easier down the road.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members