Go Back   CodingForums.com > :: Client side development > XML

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-14-2003, 04:11 PM   PM User | #1
MartinT
New to the CF scene

 
Join Date: May 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
MartinT is an unknown quantity at this point
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 ?
MartinT is offline   Reply With Quote
Old 05-16-2003, 01:27 PM   PM User | #2
Adam20002
New Coder

 
Join Date: Nov 2002
Location: London, UK
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Adam20002 is an unknown quantity at this point
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
Adam20002 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:53 AM.


Advertisement
Log in to turn off these ads.