473,388 Members | 1,097 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

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

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

Similar topics

1
by: ash | last post by:
My input file is something like this <DB> <E> <TAG1><!]></TAG1> <TAG2><!]></TAG2> <TAG3><!]></TAG3> </E> <E> <TAG1><!]></TAG1>
6
by: oooooo0000000 | last post by:
I have an XML file of varying nesting depth... <catalouge> <item id="1"> <name/> <item id="23"> <name/> <item id="55"> <name/> </item>
9
by: Stefan Franke | last post by:
Hi, I've got the following simple XSLT stylesheet, that lists all the values of the elements of any given XML file. <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0"...
9
by: gregmcmullinjr | last post by:
Hello, I am new to the concept of XSL and am looking for some assistance. Take the following XML document: <binder> <author>Greg</author> <notes> <time>11:45</time>
6
by: andyalean1 | last post by:
Hello, I am trying to match an Id number that is shared across 2 xml files.I seem to be do the right thing bu it won`t display a match.Can you please help me find my error. I have a problem matching...
0
by: napolpie | last post by:
DISCUSSION IN USER nappie writes: Hello, I'm Peter and I'm new in python codying and I'm using parsying to extract data from one meteo Arpege file. This file is long file and it's composed by...
1
by: mark4asp | last post by:
Apologies, I just can't get my head around xslt but I need to do this. I have an xml file with two attributes per product. One of the attributes repeats to produce several groups (3 in the...
1
by: Datawich | last post by:
Hi. By persistence, I've discovered that when several nested elements in a schema are each qualified by a namespace, I can successfully reference them in a select statement by qualifying each...
1
by: Hvid Hat | last post by:
Hi I want to search and replace multiple words in a text. I've got a template that does the search and replace of a word in a text. Now, I want to call this template for each word in a list of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.