S
S
Shurik2020-04-29 20:13:29
PHP
Shurik, 2020-04-29 20:13:29

How to display xml code in php beautifully (with hyphens)?

Good evening.
I have a response from the soap server in the form of an envelope:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><SOAP-ENV:getBfResponse><parameters><SOAP-ENC:Struct><id>868</id><kom1>Даллас Старз</kom1><kom2>Нэшвилл Предаторз</kom2><date>2019-04-23 03:30:00</date></SOAP-ENC:Struct><SOAP-ENC:Struct><id>12266</id><kom1>Даллас Старз</kom1><kom2>Нэшвилл Предаторз</kom2><date>2020-01-01 22:00:00</date></SOAP-ENC:Struct><SOAP-ENC:Struct><id>21206</id><kom1>Даллас Старз</kom1><kom2>Нэшвилл Предаторз</kom2><date>2020-03-07 22:00:00</date></SOAP-ENC:Struct></parameters></SOAP-ENV:getBfResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

I display the whole thing on the page:
echo "".htmlspecialchars($last_response)."";
How can I make the output human readable so that there are hyphens after the lines? I looked all over, but I didn't find anything concrete.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2020-04-29
@svisch

You shove this case into DOMDocument, set it to formatOutput , and shove it back.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question