Re: XML in XHTML
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: XML in XHTML

From: David Dorward <dorward@yahoo.com>
Date: Wed Nov 30 2005 - 22:39:51 CET

interfaced@gmail.com wrote:

> I am trying to include and xml document inside my xhtml document.

This is somewhat tricky, especially given browser support issues.

> My problem is that javascript is understanding the nodes in my xml
> document as html elements.

Presumably you are serving your XHTML with a text/html content-type, in
which case its an HTML (or possibly a "random tag soup") document, not an
XHTML document (even if it has an XHTML doctype).

> <xml>
> <book>
> <title>Lord of the Rings</title>
> </book>
> </xml>

... and you don't appear to have specified a namespace anyway (which you
can't do if you serve the document with a text/html content type).

> If I parse this, the title element cannot be extracted and the page
> title(in the browser) becomes "Lord of the Rings".

Which is the browser trying to correct for your errors.

I suggest you include the data in JSON format instead. http://www.json.org/

-- 
David Dorward       <http://blog.dorward.me.uk/>   <http://dorward.me.uk/>
                     Home is where the ~/.bashrc is
Received on Sat Dec 3 04:34:05 2005