473,385 Members | 1,838 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,385 software developers and data experts.

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

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

Jul 30 '07 #1
1 6549
Sharat Koya wrote:
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 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.
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=MVPXMLand use its
concat function <http://exslt.org/str/functions/concat/index.html>.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jul 30 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Angus McIntyre | last post by:
Can this be done with XPath? I have input XML that is basically of the form: <list> <item att="a">s1</item> <item att="a">s2</item> <item att="b">s3</item> <item att="c">s4</item> <item...
1
by: Patrick Reilly | last post by:
I am trying to implement a better method than I already have to document database schemas with XML, and use XSLT to both generate database DDL statements (CREATE TABLE, etc) and to transform to...
2
by: girish | last post by:
In my XML document, some node attributes data contains both single quot and double quote characters, such as <input msg="Hello "World", What's up"/>. The double quotes are in form of escape...
2
by: Peter Gerstbach | last post by:
Hi, I want to convert with XSLT/XPATH a String like "Aaa bbb ccc" with variant length into to "AaaBbbCcc". I think it should be possible with these steps: 1) tokenize the String with ' ' as...
1
by: DN | last post by:
I'd like to pass multiple attributes to XPath AddSort like: expr = nav.Compile(strQuery); expr.AddSort(sortArray, XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Text); But I get...
1
by: DN | last post by:
I'd like to pass multiple attributes to XPath AddSort like: expr = nav.Compile(strQuery); expr.AddSort(sortArray, XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Text); But I get...
0
by: jeoffh | last post by:
Background: I am trying to "merge" some attributes into an existing XML column in my MS SQL 2005 database. The general idea is that I have an XML column in a table and I would like to update/delete...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.