[ Microsoft.com ] – XPath Examples

XPath Examples

    XPath Examples
    ………………………………………………………………………………………………………………….
    This topic reviews the syntax examples that appear throughout the XPath Reference. All are based on the Sample XML File
    for XPath Syntax (inventory.xml).  For an example of using an XPath expression in a test file, see “Example of Unions ( | )”,
    at the bottom of this topic.


    Code Example illustrating the manipulations produced
    ………………………………………………………………………………………………………………….
    More examples from the site article itself
   
    <?xml version=’1.0′?>
    <xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”&gt;

        <xsl:template match=”root”>
           <xsl:for-each select=”x | y/x”>
              <xsl:value-of select=”.”/>,
              <xsl:if test=”not(position()=last())”>,</xsl:if>
           </xsl:for-each>
        </xsl:template>

    </xsl:stylesheet>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s