all groups > dotnet xml > july 2007 >
You're in the

dotnet xml

group:

XPATH 1.0 select a certain set of attributes and concat them.


XPATH 1.0 select a certain set of attributes and concat them. Sharat Koya
7/30/2007 10:02:07 AM
dotnet xml: I have a the following xml node.

<doc tag1="a" tag2="b" tag3="c" docTag1="d" docTag2="e"/>

I would like to output "abc"
I have the following XPATH2.0 so far

//doc/@*[name()[starts-with(.,'tag')]] which returns a node list. Note
that docTag* are ignored and there could be any number of tag*.

I managed to get a solution from microsoft.public.xml for
concatinating these using string-join function
string-join(//doc/@*[starts-with(local-name(), 'tag')], '')

however, can something similar be done in XPATH 1 as I have only just
found out that .net 2 doesn't support xpath 2.0.

Thanks in advance for any advice
Re: XPATH 1.0 select a certain set of attributes and concat them. Martin Honnen
7/30/2007 7:15:27 PM
[quoted text, click to view]

You can use SelectNodes("//doc/@*[starts-with(local-name(), 'tag')]")
with .NET and then iterate over those nodes to concatenate the attribute
values.
Or you can try to use EXSLT.NET from
<http://www.codeplex.com/Wiki/View.aspx?ProjectName=MVPXML> and use its
concat function <http://exslt.org/str/functions/concat/index.html>.



--

Martin Honnen --- MVP XML
AddThis Social Bookmark Button