469,290 Members | 1,887 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,290 developers. It's quick & easy.

Nested XPath Search

I have been trying to accomplish to populate a list of nodes that corresponds to the conditional statement in javascript. I can now search only by project name, as shown in the statement below. However, I want to be able to filter the search by Project Name and Year, and so on. I know this can easily be accomplished in XSLT. Unfortunately, I can not use dynamic XSLT in Sharepoint. Is there any way that I can search my XML file based on multiple criteria?

Expand|Select|Wrap|Line Numbers
  1. myDoc.setProperty("SelectionLanguage", "XPath");
  2.   currNode = myDoc.selectNodes("/projects/item/Project_Name[contains(@value, '" + prName.value+ "')]");
Thanks in advance.
Feb 17 '09 #1
4 3953
Dormilich
8,651 Expert Mod 8TB
I don't know what you mean by "dynamic XSLT" but it should be possible to do a selection based on passed parameters.

looking at your example, you can extend it to more than one condition. like:
Expand|Select|Wrap|Line Numbers
  1. "path/to/element[condition_1][key = 'value'][another_condition != $anything]"
Feb 17 '09 #2
Thanks for your answer.
But I can query out only one element with multiple condition parameters. The problem is how I can use multiple elements in the xpath statement.
Such as:
"path/to/element1[condition_1][key = 'value1']" AND
"path/to/element2[condition_2][key = 'value2']"
Feb 17 '09 #3
Dormilich
8,651 Expert Mod 8TB
@gorkemt
that's only a matter of the conditions. you may as well get a node-set of several elements, depending on the XPath. admittedly, the XPath will get more complex to do so.

consider this:
Expand|Select|Wrap|Line Numbers
  1. //*[* = /path/to/element1 or * = /another/path/to/element2]
Feb 17 '09 #4
Thanks for your answer.
Feb 18 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Anon | last post: by
1 post views Thread by tom | last post: by
1 post views Thread by Jerry Collings | last post: by
2 posts views Thread by kids_pro | last post: by
37 posts views Thread by Tim N. van der Leeuw | last post: by
1 post views Thread by Sergey Dubinets | last post: by
6 posts views Thread by Derek Hart | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.