Re: [xmlc] getElementsByTagName in XHTML ?
Jacob Kjome <[email protected]> Fri, 5 Aug 2005 10:46:17 -0500
| Newsgroups | gmane.comp.java.enhydra.xmlc,gmane.comp.java.enhydra.general |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format... ------------=_1123256833-26505-142 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Quoting Petr Stehlik <[email protected]>: > Hi, > > node.getTagName() returns "td" because that node is of type > HTMLTableCellElement... > You are using the HTML DOM or XHTML? From above, it looks like the HTML DO= M as the XHTML DOM would be XHTMLTableCellElement, no? Typo? > The same node.getElementsByTagName("td") returns an empty NodeList while > it should contain at least itself, IMHO. Therefore I'd say that the > getElementsByTagName method doesn't work correctly (for XHTML only?). > Well, apparently for HTML DOM since it seems that is what you are using. I= n any case, here's what the API says... /** * Returns a <code>NodeList</code> of all descendant <code>Elements</co= de> * with a given tag name, in the order in which they are encountered in * a preorder traversal of this <code>Element</code> tree. * @param name The name of the tag to match on. The special value "*" * matches all tags. * @return A list of matching <code>Element</code> nodes. */ public NodeList getElementsByTagName(String name); According to this, only descendents would be returned. I'd think it aweful= ly odd behavior that it would return itself. Was this just your opinion or ba= sed on some other part of the spec that I am unaware of? > Well, even if the getElementsByTagName was supposed to start from > children of the supplied node instead from the node itself then it still > doesn't work as I tested that case as well. > What's the test case? If you were to do node.getElementsByTagName("td") an= d the current node is a "td", I wouldn't expect to have any results returned unle= ss you were using nested tables. If you are using the HTML DOM, that should be node.getElementsByTagName("TD") anyway, since the HTML DOM stores its nodes= in upper case. > It's easy to write an implementation of getElementsByTagName that works > correctly and I am just doing that but I still wonder why the supplied > DOM method doesn't do what I'd expect. > I wonder if your expectation is valid? I also wonder if your test is valid= .=20 Can you provide the testcase you mention above so that we can verify whether there really is something wrong here? Jake > Enhydra XMLC version 2.2, Enhydra 5.1.15. > > Thanks. > > Petr > > > > ------------=_1123256833-26505-142 Content-Type: text/plain; name="message-footer.txt" Content-Disposition: inline; filename="message-footer.txt" Content-Transfer-Encoding: 8bit -- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws ------------=_1123256833-26505-142--