The moose likes XML and Related Technologies and the fly likes or condition in (Element)XPathAPI.selectSingleNode, Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "or condition in (Element)XPathAPI.selectSingleNode," Watch "or condition in (Element)XPathAPI.selectSingleNode," New topic
Author

or condition in (Element)XPathAPI.selectSingleNode,

Vallaru smitha
Ranch Hand

Joined: Aug 19, 2008
Posts: 87

Hi

i am extracting keywods from jsp using

node2=(Element)XPathAPI.selectSingleNode(rawDoc, "//meta[@name=\"keywords\"]");

but i want to check for keywords with "K" and "k". if else condition does not work as the first contidition fails sit goes to catch block.


Can any one please suggest if there is any way we could check

Thanks
smitha.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16487
    
    2

Yes, absolutely, just like you suggest, an "or" condition would do the trick. Was your question how to express "or" in XPath? Because you express "or" as "or" in XPath.

Or was your question something else?
Vallaru smitha
Ranch Hand

Joined: Aug 19, 2008
Posts: 87


Thanks Paul, I was trying with piping operator "||".

node2=(Element)XPathAPI.selectSingleNode(rawDoc, "//meta[@name=\"keywords\"]" or "//meta[@name=\"Keywords\"]");

I tried the above line but it failed.

Any suggestions....
Santhosh Kalisamy
Ranch Hand

Joined: Apr 15, 2008
Posts: 55


This will do it.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: or condition in (Element)XPathAPI.selectSingleNode,
 
Similar Threads
XPath and Modified DOM document object...
one to many bidirectional error driving me mad
searching a string a specific character sequence
casting confusion
simple question: how to return specific element value