IT Process Automation

  • 1.  How do i use xpath within JavaScript... An Example would help

    Posted Jun 25, 2014 04:00 PM

    I am trying to use xpath to work with xml data that does not have an element always in every node. I need to put in arrays for each node.

    The problem is i am not getting the xpath to give results at all

     

    I get this and example xml .. Element <EQ> will allways be present

     

    <The>

    <instance>

    <Add>One</Add>

    <EQ>Three</EQ>

    </instance>

    <instance>

    <Sub>Two</Sub>

    <EQ>Four</EQ>

    </The>

     

    I want to then create a file that has this

    "Add","Sub,"EQ"

    "One","","Three"

    "","Two","Four"

     

    I tried to start getting the data with some of this to no effect and about 1000 variation on this.

    list = applyXPath(Process[Opname].SoapSesponceBody,"/The/instance/Sub");



  • 2.  Re: How do i use xpath within JavaScript... An Example would help

    Posted Jul 23, 2014 01:16 AM

    The applyXPath function returns a string, not an array.  You can loop and use the function to get specific elements/values.  Or you can use the Apply XPath operator to get back arrays for each of the 3 element names.  According to your XML, you'd want to use xpath statements such as //Add, //Sub, and //EQ.



  • 3.  Re: How do i use xpath within JavaScript... An Example would help
    Best Answer

    Posted Jul 23, 2014 03:50 PM

    After thinking about it some more, what I said in my last post would not do what you are looking for here.  I came up with a different approach and posted an example here:  XPath Example.xml