XML handling question

I am developing an automation workflow to read xml (from SOAP response) and modify only a few tags within that and build another SOAP request.

High level steps are:

  1. Read SOAP response. Response contains tags for transaction header and multiple transaction lines
  2. Modify a few values on the transaction header tags
  3. No changes to transaction lines
  4. Build another SOAP request using transaction headers, based on new values (transaction header tags are different in response and request) and also add transaction lines as-is (transaction lines tags are same in response and request)

My approach so far:

  • Read SOAP Response XML transaction header using XPATH
  • Copy transaction lines section from into a variable
  • Build new SOAP request using by transaction header new values and add transaction lines from the variable
  • Post the new SOAP request

Challenges so far:

  • How to separate out transaction line tags alone (since there may be 1 or more lines, unable to determine how to separate out line xml sections)
<Response>
	<transaction_header>
		<Headfield1>val1</Headfield1>
		<Headfield1>val2</Headfield1>
		<Headfield1>val3</Headfield1>
		<Headfield1>val4</Headfield1>
			<Line1>Line1 values</Line1>
				<Line1 tag1>1</Line1 tag1>
				<Line1 tag2>2</Line1 tag2>
				<Line1 tag3>3</Line1 tag3>
				<Line1 tag4>4</Line1 tag4>
			<Line2>Line2 values</Line2>
				<Line2 tag1>1</Line1 tag1>
				<Line3 tag2>2</Line1 tag2>
			<Line3>Line3 values</Line3>
			<Line4>Line4 values</Line4>
			<Line5>Line5 values</Line5>
			<Line6>Line6 values</Line6>
	</transaction_header>
</Response>

Build new SOAP request by replacing transaction header values… keeping transaction lines as-is.

<RequestStart>
	<transaction_header>
		<Headfield1>valNew1</Headfield1>
		<Headfield1>valNew2</Headfield1>
		<Headfield1>valNew3</Headfield1>
		<Headfield1>valNew4</Headfield1>
			<Line1>Line1 values</Line1>
				<Line1 tag1>1</Line1 tag1>
				<Line1 tag2>2</Line1 tag2>
				<Line1 tag3>3</Line1 tag3>
				<Line1 tag4>4</Line1 tag4>
			<Line2>Line2 values</Line2>
				<Line2 tag1>1</Line1 tag1>
				<Line3 tag2>2</Line1 tag2>
			<Line3>Line3 values</Line3>
			<Line4>Line4 values</Line4>
			<Line5>Line5 values</Line5>
			<Line6>Line6 values</Line6>
	</transaction_header>
</Request>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.