1

I am using IBM Watson explorer to convert HTML to XML. There are converter where I can convert my HTML to XML using XSLT.

This is the view source of the HTML code:

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta name="ConvertedBy" content="Perceptive" />
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
        <meta name="CreationDate" content="2012/06/11 11:33:56-04'00'" />
        <meta name="Creator" content="Adobe InDesign CS5 (7.0.4)" />
        <meta name="Keywords" content="130728_47_FRM_FILI_Conservatorship" />
....
...
    </head>
</html>

What I want to do is extract the Keywords value from the meta tag. I want my XML to look like this:

<Keywords>
130728_47_FRM_FILI_Conservatorship
<Keywords>

What should I do in my XSLT? I am a newbie to XSLT. Which xpath should I specify in my XML template?

ralphearle
  • 1,696
  • 13
  • 18
Rose
  • 1,490
  • 5
  • 25
  • 56

1 Answers1

1

Something like this should work-

<xsl:template match="/">

<Keywords>
  <xsl:value-of select="html/head/meta[@name='Keywords']/@content"/>
</Keywords>

</xsl:template>

Also the xpath- //meta[@name='Keywords']/@content will work as well

Vinit
  • 1,815
  • 17
  • 38