norfleet wrote:
[color=blue]
> hi folks,
>
> OK, so let's say, for example, I have a bit of HTML that looks like
> this:
>
> <td class="regular1b" valign="top">
> <a href="notfound.html"><span class="list5"><b>Lecture
> V</b></span></a>
> </td>
>
> And I want to save all the text ("all" meaning the tags and
> everything) between the <td> and </td>. Using JavaScript, I was able
> to isolate the <td></td> by doing:
>
> var w = myTable.getElementsByTagName("TD");
>
> So then I have an IF statement within a FOR loop that looks like:
>
> if (w.item(i).className == "regular1b")
> alert(w[i].childNodes[0].nodeValue);
>
> The ALERT() is just a place holder to make sure things are working.
> The thing is, nodeValue returns NULL because there's no actual text
> within the <td></td> tags; the only thing there is more HTML code, and
> the text between the <span></span> apparently isn't considered part of
> the <td></td> tags.
>
> I guess I'm wondering if there's another way to go about getting the
> text from in between the <td></td> tags[/color]
There is. The textContent attribute in the Node interface (DOM 3 Core)
is supported by Mozil1a 1.5+. I tried it with your specific markup code
(with all the white-space, line feed, etc) and it worked without a
problem. I tried it with more complex subtree and it worked as expected.
Bug 210451: Implement Node.textContent
http://bugzilla.mozilla.org/show_bug.cgi?id=210451 http://www.w3.org/TR/2004/REC-DOM-Le...e3-textContent
For other browsers not supporting DOM 3 Node Interface, you can create a
traversal subtree function and get/fetch the text or use the
non-standard innerHTML attribute.
DU
short of just doing a[color=blue]
> brute-force text search on the whole darn page. Any help would be
> much appreciated...
>
> Fleet[/color]