Domanda

i am using simple-xml to parse some xml-Data that we get from "outside".

The XML comes the follwing way:

<element>
  <address>Name of the Customer
Street No.
ZIP City</adress>
</element>

Every line break is done with a LF.

So if i just do something like:

$xml = simplexml_load_file('file.xml');

echo $xml->element['address'];

it will just echo all the adress out in one line:

Output: Name of the Customer Street No. ZIP City

I've no possibility to change the xml (like [!CDATA..] or the like), because it is not generated by us.

Is there a way to parse the line breaks for proper output?

Any help is appreciated, because i - once again (:P) - have no idea what to do.

Best regards

È stato utile?

Soluzione

Can you test :

echo nl2br( $xml->element['address'] ) ;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top