473,566 Members | 2,785 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.publi c.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 6588
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.publi c.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.co m/Wiki/View.aspx?Proje ctName=MVPXMLan d 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
4281
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 att="c">s5</item>
1
4007
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 HTML for documentation purposes. In particular I want XSLT to transform to HTML so that my XML documents can be "live", doing the transform in the...
2
14423
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 sequence in the XML document. am not able to locate such elements using an XPath expression. I trie the following: //*
2
7175
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 separator with tokenize() 2) make the first character uppercase with substring() and upper-case() 3) put them together with concat()
1
2222
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 "Only objects returned from Compile() can be passed as input." It works fine with a single field name or attribute, but I can't seem to figure out...
1
1672
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 "Only objects returned from Compile() can be passed as input." It works fine with a single field name or attribute, but I can't seem to figure out...
0
3971
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 some values while leaving the other values alone. I am designing this database/table/column so maybe I could use attributes or elements/nodes, the...
0
7666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7584
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8108
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7644
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7951
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2083
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.