DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15122>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15122 getElementsByTagName() not (or unable) to return Comment or Text nodes Summary: getElementsByTagName() not (or unable) to return Comment or Text nodes Product: Xerces2-J Version: 2.2.1 Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: DOM AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] I have a DOM of an HTML page, which contains a table. Inside of the table are various text and comment elements (along with TR, TD, FONT, and other elements). I'm doing the following: 1) I locate the table element in the DOM /* Find the start of the sub-categories */ NodeList nodeList = document.getElementsByTagName("table"); // the forth table contains what we want. yes this is fragile. HTMLTableElement table = (HTMLTableElement)nodeList.item(3); 2) I attempt to find the Comment nodes. I've tried: a) table.getElementsByTagName("#comment") -- this returns an empty list! b) table.getElementsByTagName("!") -- I saw this being done in a JavaScript snippet, but alas, it too returns an empty list. c) NodeList nodeList = table.getElementsByTagName("*"); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node.getNodeType() == Node.COMMENT_NODE) System.out.println("Found a comment node!"); } This never finds a comment node. However, if I replace the 'if' with a simple print like this: System.out.println(node.getNodeName() + " : " + node.getNodeType() + " : " + node.getNodeValue()); It prints all of the decendents of the table -- with the EXCEPTION of text nodes (#text) and comment nodes (#comment). It was my understanding that passing "*" to getElementsByTagName() would return ALL nodes. It does not. Let me also say that if I pass 'table' to a routine which recurrsively walks the DOM from there, it does print ALL decendent elements -- including #text and #comment nodes. So, I know they're there. I think the expected behaviors should be: 1) passing "*" to getElementsByTagName() should return ALL decendents. 2) passing "#comment" or "#text" should return a collection of comment and text nodes respectively. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
