File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes DOM of current page? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "DOM of current page?" Watch "DOM of current page?" New topic
Author

DOM of current page?

S. Schaefer
Greenhorn

Joined: Feb 06, 2011
Posts: 7

Hi there.

I was just wondering if there is a way to get the DOM of the currently loaded page for example to a org.jdom.document or something like this,
so that i can get a specific node using xpath or something similar and then get the child-element of that node...?
I found HtmlUnit while "googling" (does that word even exist in english? :P), but i'm not quite sure that it does what i'm looking for ...

Looking forward to your answers and thanks in advance
gilaras
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
Current page in what?

Assuming we are talking about a HTML page, what loaded it?

If the page was coded as XHTML it can be parsed into a DOM by normal XML parsers but if was generated as HTML 4 it probably is not valid XML.

Bill
S. Schaefer
Greenhorn

Joined: Feb 06, 2011
Posts: 7

The current page shown in the firefox webbrowser ;-)
Is should have been coded in xhtml, but rendered by icefaces ... don't know if this has something to say ... ;D
So it should be XMLParser-usable ... but how does the parser get the currently rendered page?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18672
    
    8

Sure, you can access the page's DOM via Javascript. But you seem to be asking about Java. Should we assume your question involves an applet? You didn't say anything like that.
S. Schaefer
Greenhorn

Joined: Feb 06, 2011
Posts: 7

I thought i said something like that, i'm sorry ;-)

But your answer helped me nevertheless...
At least i got what i was looking for by using xpath ;-)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DOM of current page?