2014-11-25 109 views
1

嗨im新到xml并尝试检索下面显示的电话号码的值。xsl:未按预期工作的值

原始数据 -

<aboutus> 
    <title>The about us page!</title><br/> 
    <description>GameChat started in 1934 and was founded by Mr. Gary Cashew who established the business. 
    </description><br/> 
    <contact> 
     <phone>07642345537</phone><br/> 
     <email>[email protected] </email><br/> 
     <post>12 Foxtrot Road, FI23 632</post><br/> 
    </contact> 
</aboutus> 

模板试图将数据插入到表

<table border="1"> 
    <tr bgcolor="#9acd32"> 
     <th>Contact</th> 
     <th>Information</th> 
    </tr> 
    <tr> 
     <td>Phone</td> 
     <td><xsl:value-of select="phone"/></td> 
    </tr> 
    </table> 

当用我的表被创建,但尚未进入手机的价值。我可能做一个业余的错误,因此任何帮助,将不胜感激,谢谢

我所有的XLST代码看起来像这样 -

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 

    <xsl:template match="/"> 
    <html> 
     <body> 

     <table border="1"> 
      <tr bgcolor="#9acd32"> 
      <th>Contact</th> 
      <th>Information</th> 
      </tr> 
      <tr> 
      <td>Phone</td> 
      <td> 
       <xsl:value-of select="phone"/> 
      </td> 
      </tr> 

     </table> 
     </body> 
    </html> 

    </xsl:template> 

</xsl:stylesheet> 
+0

您可以发布您输入XML和XSLT完成? – 2014-11-25 01:57:53

+0

@LingamurthyCS,它刚才没有正确格式化。 – Robbert 2014-11-25 01:59:12

+1

在这种情况下我们不知道'当前节点'是什么,我们无法知道select =“phone”是否正确。例如,如果它是