locked
Get just 1 value from xml using xslt RRS feed

  • Question

  • User30110692 posted

    How cai I get just 1 value from xml using xslt?

    I have this:

    <root>
      <ROW name="start" value="12345">
        <FIELD name="start1" value=""></FIELD>
      </ROW>
      <ROW name="body" value="2323as">
        <FIELD name="outra1" value=""></FIELD>
        <FIELD name="again"  value=""></FIELD>
        <FIELD name="adeus"  value=""></FIELD>
        <FIELD name="malandro" value=""></FIELD>
      </ROW>
      <ROW name="end" value="asdad34">
        <FIELD name="regist" value=""></FIELD>
        <FIELD name="olaas"  value=""></FIELD>
      </ROW>
     </root>

    I want to get onyl the field with name: adeus in ROW with name: body and value: 2323as

    How can I use this using XSLT?

    Thanks 

    Monday, September 9, 2013 11:29 AM

Answers

  • User1220634627 posted

    <xsl:value-of select="root/ROW[@name='body' and value='2323as']/FIELD[@name='adeus']"/>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 9, 2013 12:25 PM

All replies

  • User1220634627 posted

    <xsl:value-of select="root/ROW[@name='body' and value='2323as']/FIELD[@name='adeus']"/>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 9, 2013 12:25 PM
  • User1777983149 posted

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:template match="/">
        <h1>
          <u>
            <font color="magenta">only one value</font>
          </u>
        </h1>
        <h2>
          <xsl:apply-templates select="." mode="pramod1" />
        
          <hr/>

        </h2>
      </xsl:template>

      <xsl:template match="root/ROW" mode="pramod1">

        <font color="red">

        
          <xsl:if test="@name ='body'">
            <xsl:if test="FIELD/@name ='adeus'">
            <ul>
              <!--<xsl:apply-templates select="page[@visible =1]" mode="innersitemap" />-->
              body value1:    <xsl:value-of select="FIELD/@name"/>
            </ul>
           
            </xsl:if>
          </xsl:if>
        </font>
       
     
      </xsl:template>



    </xsl:stylesheet>

    Tuesday, September 10, 2013 1:56 AM