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

XPath question

Joe
Hello All:

Is it possible to group parts of an XPath string? I need to retrieve all
ndoes from an xml document where the attribute spellCheckingRequired is equal
to "True" and the attribute controlToRender is equal to "textbox" or
"addressline" or "augmentedtextbox."

Can I group the controlToRender attributes within parentheses or is this not
required?

In other words, can I have :

[(@controlToRender='textbox' or @controlToRender='addressline' or
@controlToRender='augmentedtextbox') and @spellCheckRequired='True']

or will

[@controlToRender='textbox' or @controlToRender='addressline' or
@controlToRender='augmentedtextbox' and @spellCheckRequired='True']

produce the same result?

TIA,
--
Joe
Apr 12 '06 #1
4 1026
Hi Joe,

In Xpath, "and" has a higher precedence than "or", and these operators
are left-associative, so your expression will be evaluated as:

[((@controlToRender='textbox' or @controlToRender='addressline') or
(@controlToRender='augmentedtextbox' and @spellCheckRequired='True'))]

You should definitely use parentheses to get the result you're after.

HTH,

Chris

Apr 12 '06 #2
Joe
Chris,

Thanks for your response.

I want to retrieve all nodes that have spellCheckRequired='True' and have
either @controlToRender='textbox' or @controlToRender='augmentedtextbox' or
@controlToRender='addressline'.

Should I write the expression as:

[((@controlToRender='textbox' or @controlToRender='addressline' or
@controlToRender='augmentedtextbox') and (@spellCheckRequired='True'))]

What would be the best way to write this as an xpath? What would you
recommend?

Thanks,
--
Joe
"Chris Fulstow" wrote:
Hi Joe,

In Xpath, "and" has a higher precedence than "or", and these operators
are left-associative, so your expression will be evaluated as:

[((@controlToRender='textbox' or @controlToRender='addressline') or
(@controlToRender='augmentedtextbox' and @spellCheckRequired='True'))]

You should definitely use parentheses to get the result you're after.

HTH,

Chris

Apr 12 '06 #3
Hi Joe,

I'd go with this:

[(@controlToRender='textbox' or @controlToRender='addressline' or
@controlToRender='augmentedtextbox') and @spellCheckRequired='True']

Chris

Apr 12 '06 #4
Joe
Thanks.
--
Joe
"Chris Fulstow" wrote:
Hi Joe,

I'd go with this:

[(@controlToRender='textbox' or @controlToRender='addressline' or
@controlToRender='augmentedtextbox') and @spellCheckRequired='True']

Chris

Apr 12 '06 #5

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

Similar topics

7
by: Sebastian Petzelberger | last post by:
Hi group, please give me an example of a xpath with regex or better a link with examples. Thanks in advance, Sebastian
0
by: Bart | last post by:
Hello, I am real new to using LIBXML and have a question about XPATH evaluations. The question may show a real ignorance of the LIBXML structure, don't so assume I know what I am talking about....
3
by: Kathy Burke | last post by:
Hi again, I'm using the following xpath (works in visualizer) with a SelectSingleNode("xpath") statement. //Station/(WI])]/@order Problem is I get an error "expression passed to this method...
2
by: ree32 | last post by:
When I import an xml document in Visual studio and Genereate as schema from it, and create a dataset from it, it adds this line into to the root element of my xml file -...
9
by: David Thielen | last post by:
Hi; I am sure I am missing something here but I cannot figure it out. Below I have a program and I cannot figure out why the xpath selects that throw an exception fail. From what I know they...
5
by: Gnic | last post by:
Hi , I have an XmlDocument instance, I want to find a node in the xml, but I don't know it's path until runtime, for example <aaa> <bbb name="x"/> <aaa attr="y"> <ccc>sometext</ccc> </aaa>
7
by: Tim Hallwyl | last post by:
Hi, there! As I understand the XPaht recommendation, the context node is a node; not a node-list, not XPath object -- but a single node. Now, the WS-BPEL 2.0 specification allows an XML simple...
0
by: pompair | last post by:
Hello, I'm making a quiz game for fun. I have an xml file like this: <?xml version="1.0" encoding="utf-8" ?> <results> <index>99</index> <answers>11</answers> <questions> <question id="1">
0
by: John Krukoff | last post by:
On Wed, 2008-09-03 at 13:36 -0700, bruce wrote: Well, you could just do the test (and the count!) in the xpath expression: count( //tr/td ) It sounds like you're not familiar with xpath? I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.