The problem is, this returns only "blah blah". I think this is because it treats the < br / > tag as a separate child node, so when I do firstChild it only gets "blah blah". I want it to treat the whole text inside the < mydata > node as one child node and print it out.
I tried to use a loop to loop through the child nodes.
The problem is, the <br /> tag somehow worked as a delimiter between nodes and returned as " undefined"....
So in my output, I get:
Code:
blah blah undefinedone two
instead of this:
Code:
blah blah
one two
Which is my desired result.
What is cloneNode?
[edit]
just tried something else. I did .nodeValue instead of .data and got " null" in place of the " undefined".
if I just try to print the objects instead of data or nodeValue I get
Code:
[object text][object element][object text]
So I think I need a way to somehow print out that element as a text..
I actually wanted the whole thing inside <mydata> be treated as text string, *with* the br, p, and whatever html tags in there.
I am reading an XML file that has no "real" HTML tags in there, only my own XML tags with names like <name>, <date>, etc.
well, right now I store it in a string and then use .innerHTML to replace a text somewhere on the page with this new text.
That is the same as printing it out, I assume?
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
I just copied that from w3schools. What probably w3schools' context (and I agree with it) when it said "ignored by the parser" is the text is ignored in terms of parsing and not rendering. You've taken "ignored" out of context.