0

Using Postman I have created a POST and received a successful response which is:

    <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.009/cXML.dtd"><cXML payloadID="1291738556051.1748803078966128712@site.com" timestamp="2017-10-23 10:47:05" version="1.2.009" xml:lang="en-US"><Response><Status code="200" text="Success - Valid PunchIn" xml:lang="en-US" /><PunchOutSetupResponse><StartPage><URL><![CDATA[**https://somesite.com/shopcust_sso.asp?strfirstname=test&strlastname=test&strphone=585-427-8190&stremail=email@email.com&straccountno=test&expdate=2017-10-23 10:48 AM&straddress=274 North Goodman&strcity=Rochester&strState=NY&strzipcode=14607&payloadID=1291738556051.1748803078966128712@sciquest.com&frompunchoutURL=https%3a%2f%2fuitweb.sciquest.com%2fapps%2fRouter%2fCXMLReceive%3fsupplierId%3d13232821%26punchoutOperation%3dcreate&token=0M1d0UaQOl1XuOAbeF74%2fg%3d%3d**]]></URL></StartPage></PunchOutSetupResponse></Response></cXML>"

From this body I need to parse out:

I need to parse out the following:

https://somesite.com/shopcust_sso.asp?strfirstname=test&strlastname=test&strphone=585-427-8190&stremail=email@email.com&straccountno=test&expdate=2017-10-23 10:48 AM&straddress=274 North Goodman&strcity=Rochester&strState=NY&strzipcode=14607&payloadID=1291738556051.1748803078966128712@sciquest.com&frompunchoutURL=https%3a%2f%2fuitweb.sciquest.com%2fapps%2fRouter%2fCXMLReceive%3fsupplierId%3d13232821%26punchoutOperation%3dcreate&token=0M1d0UaQOl1XuOAbeF74%2fg%3d%3d

Then use it in a browser URL.

Thanks for the help.

Kevin K
  • 1
  • 2
  • 1
    Typically, you don't do the parsing in PostMan itself, you parse in a programming environment like Java or C#. – user3112728 Oct 23 '17 at 15:57

3 Answers3

0

I'm a bit confused about what you're asking. Depending on which language you are using, there are several libraries that will allow you to parse XML responses and pull out data you need. You can find an example on how to that here (with JS): Parse XML using JavaScript.

Once you get the URL out, you'll also need to format, since it looks like you have spaces in there. This can be done with something like Javascript's encodeURIComponent() function.

0

Using xml_grep :

xml_grep --text_only URL file.xml | sed -r 's/^\*{2}//; s/\*{2}$//'

You need to install XML::Twig

Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223
0

you could use postman's xml2json function and then parse the json. have a look here

like

// get the response body
var Json_responseBody = xml2json(responseBody);
var jsonData = JSON.parse(Json_responseBody);

and then use jsonData to extract whatever you need

I haven't tried it though ...

Community
  • 1
  • 1
A.Joly
  • 2,317
  • 2
  • 20
  • 25