0

Hey I am trying to check if there is a email present in my xml document, if yes is the password which is the sibling node the same as passed password i am getting the password and email as parameter. So far what I have tried is

<xsl:template match="/">
    <xsl:for-each select="customers//email[text()=$emailPassed] and 
      customers//password[text()=$password]">
        true
    </xsl:for-each>
</xsl:template>

The XML file is here

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

Can you please help me out with this i am stuck for quite an hour.

evilGenious
  • 777
  • 5
  • 10

1 Answers1

0

It might make more sense to use xsl:if here, but the expression you are looking for is this

    <xsl:if test="customers/customer[email=$emailPassed and password=$password]">
        <xsl:text>true</xsl:text>
    </xsl:if>

Or better still, just to this

<xsl:value-of select="boolean(customers/customer[email=$emailPassed and password=$password])" />

This will also return false in the case of no match.

Tim C
  • 70,053
  • 14
  • 74
  • 93