469,643 Members | 1,225 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

Extract nested data from XML via XSLT

I am trying to extract just a portion of data from an XML data source:

<Row>
<Col Name="Col0">123456<CellColour>36</CellColour>
<FontColour>1</FontColour>
<Bottom>1</Bottom>
<Bold>False</Bold>
<Italic>False</Italic>
<TextDirection>0</TextDirection>
</Col>
</Row>

When I extract the Col field I get "1234563612111FalsexlCenterxlBottomFalse00Fals e" using " <xsl:value-of select="Col"/>".


I just want the first portion of data "123456". I do not need any of the html tags or html data.

Any suggestions? Any direction on this would be greatly appreciated.

Thanks.
Nov 13 '07 #1
4 2138
jkmyoung
2,057 Expert 2GB
<xsl:value-of select="Col/text()"/>
or
<xsl:value-of select="Col/text()[1]"/>
Nov 13 '07 #2
That worked great!!. Thanks

One more question to extend your reply..

Each set is named "<Col Name="Col0">123456". How do I reference them by name?

ie.
Col Name="Col0">123456
Col Name="Col1">456789
Col Name="Col2">678912
Col Name="Col3">234565

Meaning each has its own name Col0, Col1, Col2, etc.

When using Col/text() it pulls only the first Col0 as that is the tag of the data set. I already have a loop setup which now grabs the first Col/text() in each set. I how do I pull them by name?
Nov 13 '07 #3
jkmyoung
2,057 Expert 2GB
Not entirely sure what you want.
Either <xsl:value-of select="Col[@name = 'Col0']/text()"/>

Or
Expand|Select|Wrap|Line Numbers
  1. <xsl:for-each select="Col">
  2.   <xsl:value-of select="@name"/>:<xsl:value-of select="text()"/>
  3. </xsl:for-each>
Nov 13 '07 #4
Perfect!!

That was exactly what I needed.

Thanks again!!
Nov 13 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by ash | last post: by
6 posts views Thread by oooooo0000000 | last post: by
9 posts views Thread by Stefan Franke | last post: by
9 posts views Thread by gregmcmullinjr | last post: by
6 posts views Thread by andyalean1 | last post: by
reply views Thread by napolpie | last post: by
1 post views Thread by Hvid Hat | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.