• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XSL Question

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have an xml in the following format.
<Employee>
<Name> Srini </Name>
<Address>
<State>VA</State>
</Address>
</Employee>

I wrote an xsl to retrieve the content of Address node
<xsl:template match="Employee">
<xsl:value-of select="Address"/>
</xsl:template>
The above lines are retrieving the value as "VA" instead of <State>VA</State>.
Please let me know is there any way to retrieve the child tags also.
Thanks in advance.
Srini
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to use
<xsl:copy-of select="Address"/>
instead of
<xsl:value-of select="Address"/>
 
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A little correction -
<xsl:copy-of> copies everything in the tree of encompassed by the supplied node and hence <xsl:copy-of select="Address"/> will give the following output -
<Address>
<State>VA</State>
</Address>
But, if you just need <State>VA</State>, you need to modify ur xpath expression as
<xsl:copy-of select="Address/State"/>
The complete output by running the stuff thru an xslt_processor looks like below -
<?xml version="1.0" encoding="UTF-8"?>
<State>VA</State>
No idea as to how to get rid of the
PI <?xml version="1.0" encoding="UTF-8"?>
in the output ........
 
Once upon a time there were three bears. And they were visted by a golden haired tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic