Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. How to make conditions or filter the xml node using XSL

How to make conditions or filter the xml node using XSL

Scheduled Pinned Locked Moved XML / XSL
xmlhelptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jollymj23
    wrote on last edited by
    #1

    Hi, I am just new to XSL. Hope anyone can help regarding my problem. Problem: I only want to display the node for ITEM/DESC and ITEM1/DESC1. How to make conditions or file the xml using XSL. THank you. jollymj23 Sample.xsl Sample.xml ITEM DESC ITEM1 DESC1 ORDER DESC

    R 1 Reply Last reply
    0
    • J jollymj23

      Hi, I am just new to XSL. Hope anyone can help regarding my problem. Problem: I only want to display the node for ITEM/DESC and ITEM1/DESC1. How to make conditions or file the xml using XSL. THank you. jollymj23 Sample.xsl Sample.xml ITEM DESC ITEM1 DESC1 ORDER DESC

      R Offline
      R Offline
      Riaan Lehmkuhl
      wrote on last edited by
      #2

      If I've got your sample correct:

      <root>
      <child>
      <node>
      <childnode>ITEM</childnode>
      <childnode>DESC</childnode>
      </node>
      <node>
      <childnode>ITEM1</childnode>
      <childnode>DESC1</childnode>
      </node>
      </child>
      <child>
      <node>
      <childnode>ORDER</childnode>
      <childnode>DESC</childnode>
      </node>
      </child>
      </root>

      You can use XPath to filter the result:

      <xsl:for-each select="//node[starts-with(string(childnode),'ITEM')]">
      <xsl:value-of select="position()"/>
      xsl:text </xsl:text>
      </xsl:for-each>

      This should print out 1 2 as it will select the first two node elements.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups