Xml XSLT试图从同级节点提取数据
嘿,我正在尝试检查我的xml文档中是否存在电子邮件,如果是,则同级节点的密码与传递的密码相同,我将获得密码和电子邮件作为参数。到目前为止,我所尝试的是Xml XSLT试图从同级节点提取数据,xml,xslt,Xml,Xslt,嘿,我正在尝试检查我的xml文档中是否存在电子邮件,如果是,则同级节点的密码与传递的密码相同,我将获得密码和电子邮件作为参数。到目前为止,我所尝试的是 <xsl:template match="/"> <xsl:for-each select="customers//email[text()=$emailPassed] and customers//password[text()=$password]"> true </
<xsl:template match="/">
<xsl:for-each select="customers//email[text()=$emailPassed] and
customers//password[text()=$password]">
true
</xsl:for-each>
</xsl:template>
真的
XML文件在这里
<?xml version="1.0"?>
<customers>
<customer>
<customerid>74</customerid>
<firstname>test</firstname>
<lastname>test</lastname>
<email>xx.xx@gmail.com</email>
<password>591c2fdfc6d2d</password>
</customer>
</customers>
74
测试
测试
xx。xx@gmail.com
591c2fdfc6d2d
你能帮我解决这个问题吗?我被困了一个小时。在这里使用
xsl:if可能更有意义,但是你要找的表达式是
<xsl:if test="customers/customer[email=$emailPassed and password=$password]">
<xsl:text>true</xsl:text>
</xsl:if>
真的
或者更好,就这样
<xsl:value-of select="boolean(customers/customer[email=$emailPassed and password=$password])" />
在不匹配的情况下,这也将返回false
。这里有一个问题,为什么在我匹配/开始时必须指定customers元素,因为/
匹配文档节点,而文档节点是根元素的父元素(customers
)谢谢Tim真的很感谢这个问题可能会提供更多信息。。。请您指导我如何调试您的xslt代码,以及在编写xslt代码时应该遵循的一些指南,谢谢