File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Can I read the tags associated with an element on the web page? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Can I read the tags associated with an element on the web page?" Watch "Can I read the tags associated with an element on the web page?" New topic
Author

Can I read the tags associated with an element on the web page?

Vasudhaiv Naresh
Ranch Hand

Joined: May 13, 2005
Posts: 57
Hi,
I was just wondering if there's any way where I can read the HTML tags associated with an element.
My requirement is as follows:
1. I have a web page.
2. I would click on some element in the web page, say a text field.
3. I would want to retrieve the HTML definition of the element.

I know there are tools like FireBug using which we can manually retrieve the information. I'm looking for someway where I write a script which lets me retrieve the tag info on click.

Thanks,
Naresh
Naresh
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

What do you mean when you say "HTML Definition"?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Vasudhaiv Naresh
Ranch Hand

Joined: May 13, 2005
Posts: 57
What I'm looking for is an application where in, if I do a click on any field of some web page, I would want to get the information of how it has been defined in the DOM.
i.e., For ex: if I click on some "button", what i'm looking for is the HTML tag which describes this element, i.e, "<input type="button"...>" in this case.
Vasudhaiv Naresh
Ranch Hand

Joined: May 13, 2005
Posts: 57
To be precise what i'm looking for a DOM inspector API.
Is there any such API available?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61187
    
  66

That information is not stored anywhere. You'd need to inspect the properties and attributes of the DOM element and recreate the markup yourself.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can I read the tags associated with an element on the web page?