This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Select specific tags in html using XSLT 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 "Select specific tags in html using XSLT" Watch "Select specific tags in html using XSLT" New topic

Select specific tags in html using XSLT

sripadraj kudur

Joined: Nov 10, 2011
Posts: 4
Hello all ,

I have been trying to parse the html and get/extract few tags from the html using xslt. My XSLT is as given below:

I need only few tags, like '<a>' and <img> in the above XSLT but the code outputs the entire html.
Can anybody point out what could have gone wrong. A sample code would be helpful.

Thank you
Paul Clapham

Joined: Oct 14, 2005
Posts: 19720

Well, yes, what you have there is basically the identity transformation, so naturally what you get as a result is basically the entire document. That's what the identity transformation does, it just copies the entire document.

So, if your desired output isn't a slightly-modified version of the entire document, then don't start with the identity transformation as the basis for your XSLT code.
I agree. Here's the link:
subject: Select specific tags in html using XSLT
It's not a secret anymore!