0

i am loading xml as String from Remote using curl as below:

$ curl -i -H "Accept: application/xml"  -X GET "URL Here"

but response is not xml format, hence not easily readable.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><RunConfig <PipeLineXmlVersion>1.0</PipeLineXmlVersion><DateTime>20161128_160859</DateTime><Analysis><Lane>1</Lane><PipeLine>run_multiplexed_auto_start_v4.0.sh</PipeLine><Version>4.0</Version><Mismatch>1</Mismatch><MergeLane>0</MergeLane<Version>4.0</Version></Analysis></RunConfig>

When i try the same API using some REST client then i can see the proper xml.

As i searched, Accept header should work but unfortunately not in my case.

Please help me with this.

Thanks.

lesnar
  • 2,400
  • 7
  • 41
  • 72
  • what do you mean by "not proper" ? Seems correct to me. – Derlin Nov 29 '16 at 07:37
  • @Derlin response is right but i expect Xml format, with proper hierarchy of nodes. Please see here one example:http://www.jonathanmedd.net/wp-content/uploads/2009/12/ExampleXML.png – lesnar Nov 29 '16 at 07:41

1 Answers1

6

If what you mean by "not proper" is the fact that the response is not pretty printed (i.e. lack spaces and indent), there are plenty of command line tools to format xml.

For example:

curl ... | xmllint --format -

Here, you pass the response of curl to xmllint (part of xmllib2-utils), which will format your answer. The - in the end tells the tool to read the input from stdin (that is, the piped content).

Have a look at this question for more ways to achieve it.

Derlin
  • 9,572
  • 2
  • 32
  • 53