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

XPath: alternatives in node-test?

kj

Suppose I wanted to select all the element nodes whose tags were
either foo or bar. One way would be to join the results of //Foo
and //bar. Is there a way to achieve the same with a single
expression that included the two alternatives? Something like
(pushing the analogy with Unix shell conventions) //{foo,bar} ?

Thanks,

kj

--
NOTE: In my address everything before the period is backwards.
Jul 20 '05 #1
3 1459
Use:

//*[self::foo or self::bar]
Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html

"kj" <so***@987jk.com> wrote in message
news:c5**********@reader1.panix.com...

Suppose I wanted to select all the element nodes whose tags were
either foo or bar. One way would be to join the results of //Foo
and //bar. Is there a way to achieve the same with a single
expression that included the two alternatives? Something like
(pushing the analogy with Unix shell conventions) //{foo,bar} ?

Thanks,

kj

--
NOTE: In my address everything before the period is backwards.

Jul 20 '05 #2
kj
In <c5***********@ID-152440.news.uni-berlin.de> "Dimitre Novatchev [MVP XML]" <dn********@yahoo.com> writes:
Use: //*[self::foo or self::bar]

Boy, you're fast!!!

Right after I posted it occurred to me to search for one more thing
in the recommendations page, namely the string "'|'" (minus the
enclosing double-quotes). I found about "UnionExpr"; so this also
works:

//foo|//bar

Thanks,

kj
--
NOTE: In my address everything before the period is backwards.
Jul 20 '05 #3

"kj" <so***@987jk.com> wrote in message
news:c5**********@reader1.panix.com...
In <c5***********@ID-152440.news.uni-berlin.de> "Dimitre Novatchev [MVP XML]" <dn********@yahoo.com> writes:
Use:

//*[self::foo or self::bar]

Boy, you're fast!!!

Right after I posted it occurred to me to search for one more thing
in the recommendations page, namely the string "'|'" (minus the
enclosing double-quotes). I found about "UnionExpr"; so this also
works:

//foo|//bar


Yes, but I understood your question as if you wanted the "//" abbreviation
to be used only once.

Also, do note that some not smart XPath engines will evaluate:
//*[self::foo or self::bar]

twice as fast as;

//foo | //bar
Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
Jul 20 '05 #4

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

Similar topics

2
by: nkunapa | last post by:
Hi: Is there a way in XPATH to find the nearest node of the node in context with a certain attribute value. Here is my problem. I have the following XML and I am trying to add all the nodes with...
3
by: sshahin | last post by:
Is there a way to Convert a Node to a String using XPath 1.0? For example, consider the following xml doc: <?xml version="1.0" encoding="UTF-8"?> <FaultTo xmlns="http://blah.org"...
0
by: XML newbie: Urgent pls help! | last post by:
HI, I am working on VB.Net.My program connects to the remote host, once the login values are verified, it sends the SessionID. My problem is Although in "Logindom" variable( in the Auto window),...
8
by: Jean-François Michaud | last post by:
Who in the name of #%@! thought this one out?? I noticed this behavior when trying to debug a problem I was having. I used this logical expression and some XPATH in a specific sequence of...
1
by: Gerben Abbink | last post by:
Hi there, I need to select all attribute nodes with value "xsd:string" using XPath. The input document is an XML Schema, e.g.: ... <xsd:element type="xsd:string"> ... Node 'xsd:element'...
4
by: Thomas Schmidt | last post by:
Given this document: <doc> <head> <someElementWithID id="X"/> <someElementWithID id="Y"/> </head> <body> <element> <otherElement>
2
by: Dave Londeck | last post by:
Given the following I am trying to get the worksheet and all of its table, rows and data so that I can then add the result it to a master xml file. This will allow me to accumlate several...
2
by: esebastian | last post by:
Hi all, Basically i want to do get the specific node that is empty but when i try the following i get a null node even though I know there is a node whose AN value is null. What am i doing wrong?...
2
by: =?iso-8859-1?q?KLEIN_St=E9phane?= | last post by:
Hi, I've a xml svg file and I would like to update it with Python. First, I would like to fetch one dom node with getElementByID. I've one issue about this method. This is my example : ...
3
rhitam30111985
by: rhitam30111985 | last post by:
Hi all, I have an xml like this : <root> <url newurl="something.asp?folder/file.htm#somethingsomething" /> <root> This is stored in a file. i am loading it at runtime like this :
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: 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
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
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.