XHTML: Return General Node When Calling GetElement Methods

"Kyle Aaron" <[email protected]>
Newsgroups gmane.comp.java.enhydra.xmlc
Message-ID <[email protected]>
I am hoping that someone might be able to answer this. Below are two very scaled down code examples. The first shows an html page and the java code to access the element once the html page has been compiled via xmlc. The second shows the same thing except for an XHTML file. In the second version, getElementSomeId() does not return an HTMLAnchorElement. Instead it returns a general element. Since element is the return type, a cast is needed to get anchor tag specific methods.

Is there a way to make XHMTL generated objects act like HTML objects so no casting is needed? 
 
 
Index.html page:
<a href=”#” id=”someId”>Click Here</a>
 
Java code used to access someId:
HTMLAnchorElement someId = indexHTML.getElementSomeId();
someId.getHref()…
 
 
When using an XHtml file it looks like this:
index.xhtml page:
<a href=”#” id=”someId”>Click Here</a>
 
Java code used to access someId:
HTMLAnchorElement someId = (HTMLAnchorElement)indexHTML.getElementSomeId();
someId.getHref()…
 



Thank you,


Kyle Aaron
[email protected]


------------------------------------------------------------------------------
This message may contain confidential information, and is intended only for the use of the individual(s) to whom it is addressed.


==============================================================================
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.