开发者

Is an XHTML doc nested inside an XHTML doc invalid?

The background to this is that we have a ASP.NET master page that reads its contents from a file supplied to us by a third party. The file that they supplied is a complete HTML document (including DOCTYPE declaration, tags with & tags also).

We then take that wrappe开发者_如何学JAVAr and insert its contents into the project’s Master pages, which also contain all of the tags that make up a complete HTML document.

Before I raise this as an issue I need to be able to tell the interested parties that this isn't valid XHTML, and that it'll wreak havoc with with the SEO.. assuming I'm correct! Can somebody confirm either way?

Thanks

Dave


Of course it's not valid to embed one (unescaped) XHTML document within another one.

But if you have no choice but to take content from one complete XHTML document and insert it into another, there might be a simple way of merging the two. For example, you could just take the contents of the <body></body> tags and discard everything else. Or if there are other things (such as stylesheets) that are required from the document, extract these from the document and merge them into the <head></head> of the master document.


It is invalid, because a page can only have one of each <html>, <head> and <body> tag. Most browsers will cope with the strange markup though, and I don't think it will mess with any Search Engines. If you mark it as XHTML, then you might get an XML error. I wouldn't advice doing it.


It's certainly be possible to embed one XML document into another one, as text. That means that the nested XML document needs all its markup escaped, either using entity/character references (&lt; etc.), or using CDATA sections.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜