Saturday, March 31, 2012

Silly question about XHTML

I think I'm having a dim day and should just go back to bed, but alas, I can
t
do that...
I'm writing a peice of code to create XHTML compliant documents using
System.IO, there's probably an easier way but anyway... my code works fine,
and it saves a file as an XML file. If I load this in IE, I get the xml
code!! (rather than the page it should generate). If I rename the file to
.xhtml, IE wont load it and I get the "choose program/service" dialog.
What am I doing wrong!?
Cheers, Dan.
Here's the generated xhtml..
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test XHTML Page</title>
<link rel="stylesheet" type="text/css" href="http://links.10026.com/?link=test.css" />
</head>
</html>
---I think you may be simply misunderstanding what IE would do with a file with
an extension of xml. It will load it and parse it as xml. If you try the
same document with an xml extension in firefox you will find it is displayed
as xhtml.
Try the document with an htm extension and it will load into IE perfectly.
If you want to keep it as a file with an xml extension then your going to
have to format it with an xsl stylesheet rather than expect the thml parser
to pick it up.
Regards
John Timney
Microsoft MVP
"musosdev" <musoswire@.community.nospam> wrote in message
news:8EEEBD74-3542-40D3-B06E-9EC6482B9B55@.microsoft.com...
>I think I'm having a dim day and should just go back to bed, but alas, I
>cant
> do that...
> I'm writing a peice of code to create XHTML compliant documents using
> System.IO, there's probably an easier way but anyway... my code works
> fine,
> and it saves a file as an XML file. If I load this in IE, I get the xml
> code!! (rather than the page it should generate). If I rename the file to
> .xhtml, IE wont load it and I get the "choose program/service" dialog.
> What am I doing wrong!?
> Cheers, Dan.
> Here's the generated xhtml..
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
> <head>
> <title>Test XHTML Page</title>
> <link rel="stylesheet" type="text/css" href="http://links.10026.com/?link=test.css" />
> </head>
> </html>
> ---
Cheers John, that makes a lot more sense - can you point me in the direction
of any tutorials on XSLT stylesheets?
Cheers
Dan
"John Timney ( MVP )" wrote:

> I think you may be simply misunderstanding what IE would do with a file wi
th
> an extension of xml. It will load it and parse it as xml. If you try the
> same document with an xml extension in firefox you will find it is display
ed
> as xhtml.
> Try the document with an htm extension and it will load into IE perfectly.
> If you want to keep it as a file with an xml extension then your going to
> have to format it with an xsl stylesheet rather than expect the thml parse
r
> to pick it up.
> --
> Regards
> John Timney
> Microsoft MVP
> "musosdev" <musoswire@.community.nospam> wrote in message
> news:8EEEBD74-3542-40D3-B06E-9EC6482B9B55@.microsoft.com...
>
>
Also, there are some good XML standard references in MSDN library, here is
the web link:
#XML Standards Reference
http://msdn.microsoft.com/library/e...c9d0-423a-a00f-
672e855de401.asp?frame=true
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
| From: "John Timney \( MVP \)" <timneyj@.despammed.com>
| References: <8EEEBD74-3542-40D3-B06E-9EC6482B9B55@.microsoft.com>
<umlIK0CHGHA.2212@.TK2MSFTNGP15.phx.gbl>
<4EFA50EC-08F6-4339-8355-6AFBA7052DE2@.microsoft.com>
| Subject: Re: Silly question about XHTML
| Date: Wed, 18 Jan 2006 17:01:03 -0000
| Lines: 79
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| Message-ID: <eHJnU8EHGHA.140@.TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 81.168.102.157
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:371796
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| http://www.w3schools.com/xsl/xsl_transformation.asp
|
| Got some good and very simple examples here
|
| --
| Regards
|
| John Timney
| Microsoft MVP
|
| "musosdev" <musoswire@.community.nospam> wrote in message
| news:4EFA50EC-08F6-4339-8355-6AFBA7052DE2@.microsoft.com...
| > Cheers John, that makes a lot more sense - can you point me in the
| > direction
| > of any tutorials on XSLT stylesheets?
| >
| > Cheers
| >
| >
| > Dan
| >
| > "John Timney ( MVP )" wrote:
| >
| >> I think you may be simply misunderstanding what IE would do with a
file
| >> with
| >> an extension of xml. It will load it and parse it as xml. If you try
| >> the
| >> same document with an xml extension in firefox you will find it is
| >> displayed
| >> as xhtml.
| >>
| >> Try the document with an htm extension and it will load into IE
| >> perfectly.
| >> If you want to keep it as a file with an xml extension then your going
to
| >> have to format it with an xsl stylesheet rather than expect the thml
| >> parser
| >> to pick it up.
| >>
| >> --
| >> Regards
| >>
| >> John Timney
| >> Microsoft MVP
| >>
| >> "musosdev" <musoswire@.community.nospam> wrote in message
| >> news:8EEEBD74-3542-40D3-B06E-9EC6482B9B55@.microsoft.com...
| >> >I think I'm having a dim day and should just go back to bed, but
alas, I
| >> >cant
| >> > do that...
| >> >
| >> > I'm writing a peice of code to create XHTML compliant documents using
| >> > System.IO, there's probably an easier way but anyway... my code works
| >> > fine,
| >> > and it saves a file as an XML file. If I load this in IE, I get the
xml
| >> > code!! (rather than the page it should generate). If I rename the
file
| >> > to
| >> > .xhtml, IE wont load it and I get the "choose program/service"
dialog.
| >> >
| >> > What am I doing wrong!?
| >> >
| >> > Cheers, Dan.
| >> >
| >> > Here's the generated xhtml..
| >> >
| >> > <?xml version="1.0" encoding="UTF-8" ?>
| >> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
| >> > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
| >> > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
| >> > <head>
| >> > <title>Test XHTML Page</title>
| >> > <link rel="stylesheet" type="text/css" href="http://links.10026.com/?link=test.css" />
| >> > </head>
| >> > </html>
| >> > ---
| >>
| >>
| >>
|
|
|
http://www.w3schools.com/xsl/xsl_transformation.asp
Got some good and very simple examples here
Regards
John Timney
Microsoft MVP
"musosdev" <musoswire@.community.nospam> wrote in message
news:4EFA50EC-08F6-4339-8355-6AFBA7052DE2@.microsoft.com...
> Cheers John, that makes a lot more sense - can you point me in the
> direction
> of any tutorials on XSLT stylesheets?
> Cheers
>
> Dan
> "John Timney ( MVP )" wrote:
>

0 comments:

Post a Comment