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

XPath filter on multiple attributes

I have the following XML:

<?xml version="1.0" encoding="UTF-8"?>
<SETTINGS>
<DATABASE NAME="DEMO" DESCRIPTION="Demo database">
<USER NAME="arnaud" />
</DATABASE>
<DATABASE NAME="TEST" DESCRIPTION="Test database">
<USER NAME="peter" DEFAULT="1" />
<USER NAME="arnaud" />
</DATABASE>
</SETTINGS>

What I want is to get the <DATABASEnode where the <USER
NAME="arnaud" DEFAULT="1">. So in the above XML there is non. But I
use the following XPath statement:

DATABASE[USER/@NAME = 'arnaud' and USER/@DEFAULT = '1']

And <DATABASETEST is returned. I expect that there is nothing to be
returned.

What do I wrong, I am new with XPATH.

Regards
Arnaud

Apr 12 '07 #1
2 25805
an*****@gmail.com wrote:
DATABASE[USER/@NAME = 'arnaud' and USER/@DEFAULT = '1']

And <DATABASETEST is returned. I expect that there is nothing to be
returned.
You want
DATABASE[USER[@NAME = 'arnaud' and @DEFAULT = '1]]

That way the filter filters on one USER element having those attribute
values while your attempt simply checks that there is one USER with NAME
attribute being 'arnaud' and a (further) USER with DEFAULT attribute
being '1'.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Apr 12 '07 #2
Thanxs, it works great.

On 12 apr, 18:11, Martin Honnen <mahotr...@yahoo.dewrote:
anxa...@gmail.com wrote:
DATABASE[USER/@NAME = 'arnaud' and USER/@DEFAULT = '1']
And <DATABASETEST is returned. I expect that there is nothing to be
returned.

You want
DATABASE[USER[@NAME = 'arnaud' and @DEFAULT = '1]]

That way the filter filters on one USER element having those attribute
values while your attempt simply checks that there is one USER with NAME
attribute being 'arnaud' and a (further) USER with DEFAULT attribute
being '1'.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Apr 12 '07 #3

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

Similar topics

8
by: Terry P | last post by:
Are there any tools (java classes, tag libraries) which can translate xpath statements into a SQL query? Given an xpath query which has a predicate that filters node values or attributes, I want...
7
by: steve bull | last post by:
I have the following code snippet to read the colorRange attributes for the colorRangeSwatch in the xml file listed below. string expr = "/swatches/colorRangeSwatch/colorRange";...
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: enrico sabbadin | last post by:
hi, while playing with the SAML specs I found that one must insert a node like this if the call succeded <status xmlns:z=mynamspace" ... <z:statuscode result="z:Sucess"/> ... How do I...
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...
2
by: Shay1975 | last post by:
What I am trying to do is filter on some attributes and I could have a list of values, so instead of doing where attribute = value or attribute = value, I am wondering if there is something...
2
by: ajayreddy2105 | last post by:
Hi All, I want to build the xpath expression dynamically in the xsl for for-each. Scenario is like this:: 1. From javascript I am sending the parameters to xsl. 2. In xsl I am taking those...
5
by: jorgedelgadolopez | last post by:
Hi all, I am using the xpathnavigator evaluate function on .net (xpath 1 right?). Now I need to expand the code to do multiple contains, compare dates (such as 'before', 'between' and 'after'),...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.