printing new line in Xpath expression result

时间:2019-01-07 13:26:05

标签: xpath

below is the input xml

 <XML>
      <json>
        <rest-adapter-response>
          <header-lines>
            <set-cookie>sap-usercontext=sap-client=300; path=/</set-cookie>
            <content-length>9834</content-length>
            <sap-perf-fesrec>37144.000000</sap-perf-fesrec>
            <content-type>application/json</content-type>
          </header-lines>
          <metadata>
            <status>success</status>
          </metadata>
          <status-line>
            <reason>OK</reason>
            <code>200</code>
          </status-line>
          <message-body>
    <IDOCDATA>
              <STATUS>
                <MESSAGE>Amount is getting mismatched while posting invoice for PO4500033056</MESSAGE>
                <STATUS>Balance not zero: 0.05-  debits: 200.45  credits: 200.40</STATUS>
                <CREATION_DATE>2016-05-20</CREATION_DATE>
              </STATUS>
              <IDOC>0000000007214348</IDOC>
            </IDOCDATA>
            <IDOCDATA>
              <STATUS>
                <MESSAGE>Amount is getting mismatched while posting invoice for PO8100999900</MESSAGE>
                <STATUS>Balance not zero: 0.20-  debits: 191,143.20  credits: 191,143.00</STATUS>
                <CREATION_DATE>2016-05-25</CREATION_DATE>
              </STATUS>
              <IDOC>0000000007219189</IDOC>
            </IDOCDATA>
    </message-body>
        </rest-adapter-response>
      </json>
    </XML>

following transformation

/XML/json/rest-adapter-response/message-body/IDOCDATA/IDOC/text()

gives following result

00000000072143480000000007219189

but my requirement is

<result>0000000007214348
        0000000007219189 </result>

that is , one new line should be added after every extracted innertext property of the tag idoc . what kind of xpath transformation could be used to achieve this ?

i want this to be done inside the xpath expression , because all these things are happening inside a too. that tool allows very minimal string manipulation functions. and extracting this result and passing this to another script which could bring the desired result and calling the script through the tool again is a tedious task. any suggestions ?

note : tool when i say here , i use bmc atrium orchestrator

0 个答案:

没有答案