Help with Looping

Discussion in 'XML' started by kumarforu, Apr 9, 2010.

  1. kumarforu

    kumarforu

    Joined:
    Apr 6, 2010
    Messages:
    2
    PLZ HELP!!!!

    For the following XML needed a output as detailed below. Will be great help for me. Thanks in Advance.

    <SubEligBenInfo>
    <sSubDateTimeType2110>
    <string>Completion</string>
    <string>Expires</string>
    <string xsi:nil="true" />
    <string xsi:nil="true" />
    <string xsi:nil="true/>
    </sSubDateTimeType2110>
    <sSubDateTimeFormat2110>
    <string>CCYYMMDD</string>
    <string>YYMMDD</string>
    <string xsi:nil="true" />
    <string xsi:nil="true" />
    <string xsi:nil="true" />
    </sSubDateTimeFormat2110>
    <sSubDateTimePeriod2110>
    <string>20050401</string>
    <string>20060401</string>
    <string xsi:nil="true" />
    <string xsi:nil="true" />
    <string xsi:nil="true" />
    </sSubDateTimePeriod2110>
    </SubEligBenInfo>

    OUTPUT:

    Completion
    CCYYMMDD
    20050401

    Expires
    YYMMDD
    20060401
     
    kumarforu, Apr 9, 2010
    #1
    1. Advertisements

  2. kumarforu

    aljar

    Joined:
    May 15, 2010
    Messages:
    5
    Hello,

    I am not sure what your are trying to acheive. Besides the string elements that are empty with same value attributes, the other string elements have unique parent nodes. So I can't see any looping here. Now here is an partial xsl (this thing does not allow xmlns links etc...) giving your ouput with no loop. I removed the empty string elements from xml.

    Code (Text):


        <!-- Override default template behaviour i.e. do display str elemnts -->
        <xsl:template match="string" />
       
        <xsl:template match="/SubEligBenInfo">
            <html>
                <head>
                    <title>Insert Your Title Here</title>
                </head>
                <body>
                    <!-- TODO: Auto-generated template -->
                    <xsl:value-of select="sSubDateTimeType2110/string[1]" />
                    <br />
                    <xsl:value-of select="sSubDateTimeFormat2110/string[1]" />
                    <br />
                    <xsl:value-of
                        select="sSubDateTimePeriod2110/string[1]" />
                    <br />
                    <br />
                    <xsl:value-of select="sSubDateTimeType2110/string[2]" />
                    <br />
                    <xsl:value-of select="sSubDateTimeFormat2110/string[2]" />
                    <br />
                    <xsl:value-of select="sSubDateTimePeriod2110/string[2]" />

                </body>
            </html>
        </xsl:template>
    </xsl:stylesheet>
     
    hope this will help
     
    aljar, May 15, 2010
    #2
    1. Advertisements

  3. kumarforu

    aljar

    Joined:
    May 15, 2010
    Messages:
    5
    more loop

    You can also avoid hard coding the indices 1 and 2 by using a call template that works recursively like a for loop ;-)

    aljar
     
    aljar, May 19, 2010
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Trevnal
    Replies:
    4
    Views:
    456
    Harald
    May 1, 2005
  2. Lance Hoffmeyer
    Replies:
    1
    Views:
    318
    Peter Otten
    Feb 16, 2007
  3. Lance Hoffmeyer

    Newbie help looping/reducing code

    Lance Hoffmeyer, Feb 19, 2007, in forum: Python
    Replies:
    3
    Views:
    324
    Cameron Laird
    Feb 20, 2007
  4. thelane
    Replies:
    1
    Views:
    459
    Owen Jacobson
    Dec 10, 2007
  5. giuseppe.amatulli@gmail.com

    looping in array vs looping in a dic

    giuseppe.amatulli@gmail.com, Sep 20, 2012, in forum: Python
    Replies:
    5
    Views:
    357
Loading...

Share This Page