Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Vasudhaiv Naresh
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean when you say "HTML Definition"?
 
Vasudhaiv Naresh
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To be precise what i'm looking for a DOM inspector API.
Is there any such API available?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That information is not stored anywhere. You'd need to inspect the properties and attributes of the DOM element and recreate the markup yourself.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!