tags:

views:

92

answers:

2

Hi , Is it possible to add a conditional statement to XML document ?

Thank in advance

+3  A: 

The question doesn't really make sense. An XML document is just a document. It may represent some sort of execution flow, but that's specific to the kind of XML document it is.

There's no "general" idea of a conditional bit of an XML document - and really no idea of a "statement" in XML either.

What are you really trying to do? What's the concrete problem you're trying to solve?

Jon Skeet
Sorry, concrete problems belong on BrickLayer.com
Jeff Yates
<big grin> <hehe>
marc_s
+2  A: 

As Jon states, XML has no general idea of conditions. However, if you are referring to XSLT, a format based upon XML that is used for translation of one text format to another, then you are looking for the xsl:choose element.

You use it like this (from W3 Schools):

  <xsl:choose>
    <xsl:when test="price &gt; 10">
      <td bgcolor="#ff00ff">
      <xsl:value-of select="artist"/></td>
    </xsl:when>
    <xsl:otherwise>
      <td><xsl:value-of select="artist"/></td>
    </xsl:otherwise>
  </xsl:choose>
Jeff Yates