Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: XPath problem!

  1. #1
    New to the CF scene
    Join Date
    May 2003
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    XPath problem!

    I got a simple xml file
    Code:
    <root>
      <cat>
         <id>0</id>
         <value>white</value>
         <details>...</details>
      </cat>
      <cat>
         <id>1</id>
         <value>black</value>
         <details>...</details>
      </cat>
    </root>
    I need an xpath that will select only the id and value node

    the output should like this:
    Code:
    <root>
      <cat>
         <id>0</id>
         <value>white</value>
      </cat>
      <cat>
         <id>1</id>
         <value>black</value>
      </cat>
    </root>
    Anyone can help ?

  • #2
    New Coder
    Join Date
    Nov 2002
    Location
    London, UK
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts
    my xml/xsl is a little rusty but something like this :-

    Code:
    <?xml version="1.0"?>
    
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes"/>
    <xsl:template match="/">
    
    <root>
    	<xsl:for-each select="/root/cat">
    		<cat>
    			<id><xsl:value-of select="./id" /></id>
    			<value><xsl:value-of select="./value" /></value>
    		</cat>
    	</xsl:for-each>
    </root>
    
    </xsl:template>
    </xsl:stylesheet>
    ?

    Adam


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •