File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Fetching TagName in XSL 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 "Fetching TagName in XSL" Watch "Fetching TagName in XSL" New topic

Fetching TagName in XSL

Priya Jotwani
Ranch Hand

Joined: Oct 30, 2002
Posts: 53
I have an XML file which has some Tags and its values.Can somebody tell me as to how can I find TagName and its corresponding values ?
Suppose , i have an entry like this :


How can i fetch Tag 'Name' and its value 'Priya' using XSL.

Rahesh Kumar
Ranch Hand

Joined: Sep 10, 2004
Posts: 53
Hi Priya Jotwani
restructure your xml as the one below

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="Test.xsl"?>
and save it as Test.xml

have your xsl as the one below
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl=""
<xsl:template match="/">

<xsl:for-each select="Root">
<xsl:value-of select="Name"/>




save it as Test.xsl.

The href in ur xml file is the way by which u map ur xml to xsl,and the template match in ur xsl in going to the root node,actually u cannot retrieve any dat without having a root node in ur xml,so have a root node as named as Root in the xml the syntax to select the attribute is value-of select.This is the way to retrieve the data from ur chile tag,i dont think we can retrieve the tag name.

I agree. Here's the link:
subject: Fetching TagName in XSL
It's not a secret anymore!