471,086 Members | 934 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,086 software developers and data experts.

Cannot append a node from XML into the HTML dom in IE

I cannot append a node from XML into the HTML dom (textarea field) in
IE. But I can for the text input html elements! Is anyone aware of
this and what is the possible solution?
Thanks.

Apr 19 '07 #1
7 3149
vu******@gmail.com wrote:
I cannot append a node from XML into the HTML dom (textarea field) in
IE. But I can for the text input html elements! Is anyone aware of
this and what is the possible solution?
The XML DOM IE uses is implemented by MSXML, the HTML DOM IE uses by
MSHTML. These are separate DOM implementations and you cannot move nodes
from one implementation to the other. It usually makes no sense
attempting that anyway as XML nodes make no sense in a HTML document. IE
supports XML data islands however where you can embed XML in HTML, to do
that you need to create an HTML element with tag name 'xml' and then
that element can contain an XML DOM.
If your XML DOM contains XHTML elements and that is the reason why you
want to move the nodes into the HTML document then with IE you need to
use the serialized markup (xml property of an XML DOM node) and insert
that into the HTML DOM with innerHTML or insertAdjacentHTML.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 20 '07 #2
On Apr 20, 6:37 am, Martin Honnen <mahotr...@yahoo.dewrote:
vunet...@gmail.com wrote:
I cannot append a node from XML into the HTML dom (textarea field) in
IE. But I can for the text input html elements! Is anyone aware of
this and what is the possible solution?

The XML DOM IE uses is implemented by MSXML, the HTML DOM IE uses by
MSHTML. These are separate DOM implementations and you cannot move nodes
from one implementation to the other. It usually makes no sense
attempting that anyway as XML nodes make no sense in a HTML document. IE
supports XML data islands however where you can embed XML in HTML, to do
that you need to create an HTML element with tag name 'xml' and then
that element can contain an XML DOM.
If your XML DOM contains XHTML elements and that is the reason why you
want to move the nodes into the HTML document then with IE you need to
use the serialized markup (xml property of an XML DOM node) and insert
that into the HTML DOM with innerHTML or insertAdjacentHTML.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Thank you for a very good explanation. So, if I understood correctly,
if I have an XML Http Request response object named, say, myXHR, and I
would want to place one of its node values to textarea in IE, then I
would do something similar to this:

document.getElementById('myTextArea').insertAdjace ntHTML('afterBegin',
myXHR.documentElement.getElementsByTagName("someno de")
[0].firstChild.nodeValue)

Do I need to do the same for text input elements too? Though it works
well doing this in IE (why?):

document.getElementById('myInput').value =
myXHR.documentElement.getElementsByTagName("someno de")
[0].firstChild.nodeValue;

Thanks

Apr 20 '07 #3
vu******@gmail.com wrote:
if I have an XML Http Request response object named, say, myXHR, and I
would want to place one of its node values to textarea in IE, then I
would do something similar to this:

document.getElementById('myTextArea').insertAdjace ntHTML('afterBegin',
myXHR.documentElement.getElementsByTagName("someno de")
[0].firstChild.nodeValue)
For textarea element I would not bother with insertAdjacentHTML, text
controls have a value property to set the text so simply use that as you
do below.

document.getElementById('myInput').value =
myXHR.documentElement.getElementsByTagName("someno de")
[0].firstChild.nodeValue;
insertAdjacentHTML makes sense for elements like div or span elements.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 20 '07 #4
On Apr 20, 10:09 am, Martin Honnen <mahotr...@yahoo.dewrote:
vunet...@gmail.com wrote:
if I have an XML Http Request response object named, say, myXHR, and I
would want to place one of its node values to textarea in IE, then I
would do something similar to this:
document.getElementById('myTextArea').insertAdjace ntHTML('afterBegin',
myXHR.documentElement.getElementsByTagName("someno de")
[0].firstChild.nodeValue)

For textarea element I would not bother with insertAdjacentHTML, text
controls have a value property to set the text so simply use that as you
do below.
document.getElementById('myInput').value =
myXHR.documentElement.getElementsByTagName("someno de")
[0].firstChild.nodeValue;

insertAdjacentHTML makes sense for elements like div or span elements.

--

Martin Honnen
http://JavaScript.FAQTs.com/
That's the problem. I am unable to use value for textarea in IE. Maybe
I am doing something wrong?...

Apr 20 '07 #5
On Apr 20, 10:09 am, Martin Honnen <mahotr...@yahoo.dewrote:
vunet...@gmail.com wrote:
if I have an XML Http Request response object named, say, myXHR, and I
would want to place one of its node values to textarea in IE, then I
would do something similar to this:
document.getElementById('myTextArea').insertAdjace ntHTML('afterBegin',
myXHR.documentElement.getElementsByTagName("someno de")
[0].firstChild.nodeValue)

For textarea element I would not bother with insertAdjacentHTML, text
controls have a value property to set the text so simply use that as you
do below.
document.getElementById('myInput').value =
myXHR.documentElement.getElementsByTagName("someno de")
[0].firstChild.nodeValue;

insertAdjacentHTML makes sense for elements like div or span elements.

--

Martin Honnen
http://JavaScript.FAQTs.com/
In other words, when I do

document.getElementById('myTextarea').value =
myXHR.documentElement.getElementsByTagName("someno de")
[0].firstChild.nodeValue;

I cannot see anything in that textarea in IE6, but I see it in text
input field. Moreover, when I use some function to grab value of
textarea (which is invisible in my IE), it exists and can be passed on
to another function... That was the problem of my question. If anyone
can suggest anythiing, please let me know.
Thank you

Apr 20 '07 #6
vu******@gmail.com wrote:
document.getElementById('myTextarea').value =
myXHR.documentElement.getElementsByTagName("someno de")
[0].firstChild.nodeValue;

I cannot see anything in that textarea in IE6, but I see it in text
input field.
textarea is a TEXT area. You cant add HTML content in a TEXTarea.

Apr 21 '07 #7
On Apr 20, 11:29 pm, "scripts.contact" <scripts.cont...@gmail.com>
wrote:
vunet...@gmail.com wrote:
document.getElementById('myTextarea').value =
myXHR.documentElement.getElementsByTagName("someno de")
[0].firstChild.nodeValue;
I cannot see anything in that textarea in IE6, but I see it in text
input field.

textarea is a TEXT area. You cant add HTML content in a TEXTarea.
And the answer is: This does not work in my IE6 because of
"Description" name

document.getElementById('Description').value =
myXHR.documentElement.getElementsByTagName("Descri ption")
[0].firstChild.nodeValue;

Apr 23 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Robert Mark Bram | last post: by
2 posts views Thread by Michael Lee | last post: by
3 posts views Thread by J Krugman | last post: by
3 posts views Thread by David Elliott | last post: by
2 posts views Thread by tepaul | last post: by
4 posts views Thread by glbdev | last post: by
7 posts views Thread by dennis.sprengers | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.