...

View Full Version : XPath problem!



MartinT
05-14-2003, 05:11 PM
I got a simple xml file


<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:


<root>
<cat>
<id>0</id>
<value>white</value>
</cat>
<cat>
<id>1</id>
<value>black</value>
</cat>
</root>


Anyone can help ?

Adam20002
05-16-2003, 02:27 PM
my xml/xsl is a little rusty but something like this :-




<?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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum