xml inline html

M

Michael Hill

I was wondering if it is possible to include a xml structure in your html
document.

For example given the below snippet the function "dothis()" will return 0
and "dothat()" will return 1.

If I can use xml in html I should be returning 1 for both functions.

Thanks,

Mike

<script>
function dothis()
{
var xxx = document.getElementById('xmlid');
alert(xxx.childNodes.length);
}
function dothat()
{
var xxx = document.getElementById('tblid');
alert(xxx.childNodes.length);
}
</script>

<xml id="xmlid">
<data>
<first>abc</first>
</data>
</xml>

<table id="tblid">
<tr>
<td>abc</td>
</tr>
</table>
 
T

Tjerk Wolterink

Michael said:
I was wondering if it is possible to include a xml structure in your html
document.

For example given the below snippet the function "dothis()" will return 0
and "dothat()" will return 1.

If I can use xml in html I should be returning 1 for both functions.

Thanks,

Mike

<script>
function dothis()
{
var xxx = document.getElementById('xmlid');
alert(xxx.childNodes.length);
}
function dothat()
{
var xxx = document.getElementById('tblid');
alert(xxx.childNodes.length);
}
</script>

<xml id="xmlid">
<data>
<first>abc</first>
</data>
</xml>

<table id="tblid">
<tr>
<td>abc</td>
</tr>
</table>


I think it is possible in xhtml 1.0 strict, but you should define an namespace for the non-xhtml elements.
I do now know if document.getElementById is possible, i think the getElementById method in the DOM is html only.
You should check W3C DOM if getElementId is also defined for plain xml
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,835
Latest member
lila30

Latest Threads

Top