473,395 Members | 2,436 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,395 software developers and data experts.

XPath Query (Multiple Parameters)

Ash
Hi,

Using this sample XML ......
<Data>
<House>
<Location> London </Location>
<Type> Detached </Type>
<Value> 200,000 </Value>
</House>
<House>
<Location> London </Location>
<Type> Flat </Type>
<Value> 100,000 </Value>
</House>
</Data>
Is it possible to generate an xpath query which will locate all house nodes
which have a location = "London" and Type = "Flat".

Regards

Ash.
Nov 21 '05 #1
3 4838
"Ash" <am*****@onet.co.uk> schrieb:
<Data>
<House>
<Location> London </Location>
<Type> Detached </Type>
<Value> 200,000 </Value>
</House>
<House>
<Location> London </Location>
<Type> Flat </Type>
<Value> 100,000 </Value>
</House>
</Data>

Is it possible to generate an xpath query which will locate all house
nodes
which have a location = "London" and Type = "Flat".


Untested (!):

"//Data/House[@Location='London' and @Type='Flat']"

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #2
Hi Ash!

"Ash" schrieb
Using this sample XML ......
<Data>
<House>
<Location> London </Location>
<Type> Detached </Type>
<Value> 200,000 </Value>
</House>
<House>
<Location> London </Location>
<Type> Flat </Type>
<Value> 100,000 </Value>
</House>
</Data>
Is it possible to generate an xpath query which will locate all house
nodes
which have a location = "London" and Type = "Flat".


Herfried's solution works for selecting attributes, not the value of
elements.

If you want to select elements (like in your example):

//Data/House/Location [normalize-space(string()) = 'London']/../Type
[normalize-space(string()) = 'Flat']/..

I used normalize-space() to make the XPath-Query work with " London " or
"London".

Cheers

Arne Janning
Nov 21 '05 #3
"Arne Janning" <sp*****************@msn.com> schrieb:
Herfried's solution works for selecting attributes, not the value of
elements.


Ooops... Yes, you are absolutely right... I should definitely take more
sleep...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #4

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

Similar topics

2
by: R | last post by:
Hello everybody. I'm new to XML and I've got problem with one XPath query. This is my situation: <group> <test required='1'></test> <test required='1' noregexp='1'></test> </group> inside...
2
by: David Gordon | last post by:
Hi Folks, I wonder if anyone can help me with the following (perhaps trivial) problem: <xml> <node name="a" type="a"/> <node name="b" type=""/> <node name="c"/> <node name="d" type="b"/>...
5
by: John Bailo | last post by:
I wrote a webservice to output a report file. The fields of the report are formatted based on information in an in-memory XmlDocument. As each row of a SqlDataReader are looped through, a...
3
by: IMS.Rushikesh | last post by:
Hi Friends, I need a XPath query, whcih ll return me subset of data.... check below xml stream <label id="MyExpenseDetails_lbl" xlink:role="terseLabel">Short Expense Details</label> <label...
1
by: Bob | last post by:
Is it possible to create an XPath query that will return both the First and Last names using the following as an example? <Data> <Emp> <FirstName>Karen</FirstName> <LastName>Wade</LastName>...
2
by: mel_dev | last post by:
All, I'm brand new to XML and have been given a deadline to deliver some new functionality part of which requires stepping through an xml doc. I have hit a wall with the way I've structured an...
1
by: Steven K | last post by:
Hello, I am calling a SQL Server 2K parameter query with the following: Dim spWebDocGroup As OleDb.OleDbDataReader Dim prmWebDocGroup As OleDbParameter Dim cmdWebDocGroup As New...
3
by: Jason Mobarak | last post by:
Hello -- I'm attempting to get a handle on how to do xpath queries with System.Xml -- so far the biggest hurdle has been how to deal with a default namespace. If I use the test xml: <?xml...
2
by: =?Utf-8?B?RGlmZmlkZW50?= | last post by:
Hello All, I am trying to construct an XPath query against an XML document, for a requirement that I have. Below is the XML fragment: <SUBMISSIONS> <SUBMISSION YEAR="2004"> <MONTH...
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: 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...
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
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...
0
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...
0
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,...

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.