Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Windows batch to get XML with cURL and parse field

I need to know if its possible to make a curl, and with a XML response, parse a field and get that value in a variable within a windows batch file.

My idea is to do the following curl:

curl -X GET "http://server/app/rest/buildTypes/id:4545785/builds?count=1&state=finished"

which returns the following XML:

<?xml version="1.0" encoding="UTF-8"?>
<builds count="1" href="/app/rest/buildTypes/id:4545785/builds?count=1&amp;state=finished" nextHref="/app/rest/buildTypes/id:4545785/builds?state=finished&amp;locator=start:1,count:1">
   <build id="52" buildTypeId="4545785" number="51" status="SUCCESS" state="finished" href="/app/rest/builds/id:52" webUrl="http://server/viewLog.html?buildId=52&amp;buildTypeId=4545785" />
</builds>

I need to extract the value of status and then exit batch with a specific code: if "SUCCESS" exit with 0 or else exit with -1.

Is this possible?

Comments