4 Replies Latest reply on Nov 6, 2007 10:51 AM by HowardTreisman

    XPath and XML nodes

    Level 1
      Hello

      I've a simple problem but can't figure out the solution in ES Workbench (Process Designer). My process uses a xml variable called xmlvar that looks like:

           
              
                 
                     form 1
                 

                 
                     form 2
                 

                 
                     form 3
                 

              

           


      For example: I want to get the name of the second anyform element. My index is stored in a counter variable called posCount (type int) and the value is 1. I've tried the XPath selection:
      /process_data/xmlvar/data/formList/anyform[/process_data/posCount]/name

      That doesn't work. I'm always getting the first value ("form 1").

      Anybody know why?
      Nico
        • 1. Re: XPath and XML nodes
          Jasmin Charbonneau Level 4
          Nico,
          I have copy/pasted your XML into a file and created a process that reads the file from the file system, put the content into an XML variable and then use /process_data/xmlvar/data/formList/anyform[2]/name to put the name in a string variable and I do get "form 2".

          Are you sure you're xml variable is populated properly? Can you put a variable logger before your SetValue to double check the content of the variable?

          Jasmin
          • 2. Re: XPath and XML nodes
            Level 1
            Strewth! This one was nasty... but finally I made it.

            My approach had two failures:
            * xml nodes, maps, list have not 0-based but 1-based indexes
            * the statement has wrong syntax (but this doens't result in an exception!!)

            Ok, the correct statement look like this if your index is also a variable:
            /process_data/xmlvar/data/formList/anyform[number(/process_data/posCount)]/name

            That's it!
            Nico
            • 3. Re: XPath and XML nodes
              Level 1
              Thanks Jasmin for your great support!
              Unfortunately I could solve my problem (almost) in the same minute as you were testing my problem.... sorry.

              Nico
              • 4. Re: XPath and XML nodes
                HowardTreisman Level 1
                Hi Nico
                The xpath expression probably doesn't throw an exception because it's still a valid xpath expression, it just doesn't result in the data that you're expecting.

                What would be very helpful in xpath expressions is a way of evaluating an xpath expression against the real data of a particular process instance. If you feel this would be useful, please log it as a feature request with Adobe.

                Howard
                http://www.avoka.com