2017-03-01 35 views
1

我正在使用IBM Watson Explorer将HTML转换为XML。有转换器,我可以使用XSLT将我的HTML转换为XML。如何使用XSLT将HTML的视图源转换为XML?

这是HTML代码的查看源代码:

<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> 

我想要做的是提取的元标记关键字的值。我想我的XML看起来像这样:

<Keywords> 
130728_47_FRM_FILI_Conservatorship 
<Keywords> 

我应该在我的XSLT中做什么?我是XSLT的新手。我应该在我的XML模板中指定哪个xpath?

回答

1

这样的事情应该与工作

<xsl:template match="/"> 

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

</xsl:template> 

另外,xpath- //meta[@name='Keywords']/@content将工作以及

+1

感谢,对于摄影指导Vinit的XSLT – Rose