5 Replies Latest reply on Mar 27, 2019 7:31 AM by Carl Wilson

    Help with xpath

    Kushagra Jain
      Share:|

      Hi Everyone,

       

      I am trying to show the result of a powershell output in a operator dialogue activity description so that user can see the outcome. My output is somewhat like this:-

       

      <output>

      <line index="1"></line>

      <line index="2">SCCMuninstall.bat failed with error : System.Management.Automation.RemoteException: The service name is invalid. ,</line>

      <line index="3">[ Service Status after uninstall]</line>

      <line index="4">[ AdaptivaClient - AdaptivaClient not found]</line>

      </output>

       

      When i use the xpath //output/line/text() it gives me all the output in one single line that is not readable. 

       

      Is there any way i can get output of above xml in operator dialogue activity description as below in multiple lines :-

       

      SCCMuninstall.bat failed with error : System.Management.Automation.RemoteException: The service name is invalid. ,

      [ Service Status after uninstall]

      [ AdaptivaClient - AdaptivaClient not found]

        • 1. Re: Help with xpath
          Sae Park

          Does it have to be xpath? I know I can do it in xslt, but I don't think it's possible with xpath.

          <xsl:for-each select="//line">

                  <xsl:value-of select="string(.)" disable-output-escaping="no" />

                  <xsl:text disable-output-escaping="no">

          </xsl:text>

                </xsl:for-each>

          • 2. Re: Help with xpath
            Kushagra Jain

            Thanks Sae!!

             

            It worked but i am getting xml declaration in output .. <?xml version="1.0" encoding="UTF-8"?> ... can i remove it in any way

            • 3. Re: Help with xpath
              Sae Park

              Maybe you can put the output through another basic xml to string transform?

              • 4. Re: Help with xpath
                Henrik Hauchwitz

                Hi Kushagra,

                 

                I guess a quick and dirty way of doing what you'd like to achieve would be to extract the text of each line separately and then concatenate the results.
                For extraction of single lines something like //line[@index="2"]/text() would work.

                 

                Save that to a configuration item, repeat for the remaining lines and finally use an assign activity, where you can insert linefeeds inbetween configuration items. Here's an example of what I mean.

                 

                Keep in mind though that, should you go for this approach, it is rather unstable since the extraction relies on line indices or in other words an output very similiar to what you gave as an example.

                 

                Best regards,

                Henrik

                3 of 3 people found this helpful
                • 5. Re: Help with xpath
                  Carl Wilson

                  Hi,

                  another option (if wanting to use XPATH) is to use a "Basic" transform and select the "To Text - Multiple Line" option (or similar) in the String utilities.

                  If wanting the exact XPATH, you can look at the PDL output from the workflow that will show you exactly what the basic operations are in their XPATH equivalents.

                   

                  Cheers

                  Carl

                  2 of 2 people found this helpful