var page = <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Foo</title>
</head>
<body>
Bar
</body>
</html>
This works fine and I can see that the literal has been assigned to
the variable properly, but I seem to be unable to access the
descendants of page. e.g. if I write
page..head
It just shows a blank line. Presumably that means it's returning null,
undefined, or something similar?
It's the xmlns declaration that seems to be causing it trouble. If I
remove it then I can access the descendants normally.
Am I doing something wrong, or is this a bug?
David
It returns an empty XML list.
The XHTML elements are in a namespace so with E4X you either need to declare
default xml namespace = 'http://www.w3.org/1999/xhtml';
then you can use
page..head
or you need to use a "namespace prefix" e.g.
var xhtml = new Namespace('http://www.w3.org/1999/xhtml');
then you can access
page..xhtml::head
--
Martin Honnen
http://JavaScript.FAQTs.com/
Ah ha, right. I should have thought of that. Thank you.