-1

I am sending XML requests with cURL, and server is responding with XML data, which is displayed as single line string, I want to represent data as classical XML structure like this:

<command>
    <check>
      <domain:check>
        <domain:name>domena1.hr</domain:name>
        <domain:name>domena2.hr</domain:name>
      </domain:check>
    </check>
    <clTRID>05106558-94309643</clTRID>
  </command>

Data is returned as curl_exec, and in string format, only with values.

Alan Kis
  • 1,790
  • 4
  • 24
  • 47
  • 1
    If you're viewing the xml on a web browser, view the source code, if the xml is well encoded, it will maintain it's structure. – Pedro Lobito May 08 '15 at 20:32

1 Answers1

1

What you're talking about is called pretty printing. Semantically, the linefeeds and indent is irrelevant to XML.

Personally - I'd install the perl XML::Twig library, because one of the utilities it also installs is xml_pp. Which basically does:

perl -e 'XML::Twig -> new ( pretty_print => 'indented' ) -> parse ( \*STDIN ) -> print;'

But most languages and parses can do it - just look up 'pretty print'.

Sobrique
  • 52,974
  • 7
  • 60
  • 101