Finding syntactically-related children and parent Elements in XHTML.

Hello everyone.

Just picking your brains on something you might have come across while
playing with JDOM, JTidy or similar components...

I'm trying to get my algorithm to understand which elements are
syntactically directly related to their parents in an XHTML structure.

For example, I want the system to know that all TD and TR elements are
directly related to their TABLE parent (i.e. they can't exist without it)
where as for example a P element within a TD is not "syntactically directly"
related to its TD or TR or TABLE parents (i.e. a P can be found on its own
within the XHTML document without always requiring TD to be its parent
element).

I was wondering if such a relation is easily detectable using something like
JDOM, Jtidy etc.?

I've been experimenting with getDescendants() and getChildren() methods but
both of them return every child or descendant regardless of the direct
syntactic relation it may have with its parents...

Just wondering if you've ever come across such an issue or can think of a
possible solution...

Been busting my head all day to try to find a "clean" way of doing this...

C.

Received on Monday, 2 May 2005 16:21:23 UTC