Nested XPath Search

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gorkemt
    New Member
    • Feb 2009
    • 3

    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?

    Code:
    myDoc.setProperty("SelectionLanguage", "XPath");
      currNode = myDoc.selectNodes("/projects/item/Project_Name[contains(@value, '" + prName.value+ "')]");
    Thanks in advance.
    Last edited by Dormilich; Feb 17 '09, 10:34 PM. Reason: added [code] tags
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    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:
    Code:
    "path/to/element[condition_1][key = 'value'][another_condition != $anything]"

    Comment

    • gorkemt
      New Member
      • Feb 2009
      • 3

      #3
      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']"

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        Originally posted by gorkemt
        But I can query out only one element with multiple condition parameters.
        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:
        Code:
        //*[* = /path/to/element1 or * = /another/path/to/element2]

        Comment

        • gorkemt
          New Member
          • Feb 2009
          • 3

          #5
          Thanks for your answer.

          Comment

          Working...