# New Lines in XML files

**URL:** <https://forum.kirupa.com/t/new-lines-in-xml-files/25423>\
**Category:** programming\
**Created:** [July 12, 2003, 5:00pm UTC](https://forum.kirupa.com/t/new-lines-in-xml-files/25423 "2003-07-12T17:00:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adityagaddam](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@adityagaddam](https://forum.kirupa.com/u/adityagaddam)\
**Post date:** [July 12, 2003, 5:00pm UTC](https://forum.kirupa.com/t/new-lines-in-xml-files/25423/1 "2003-07-12T17:00:30Z")

</div>

oki… I have to have a block of text to be saved in an XML file. But when I have newlines in the XML file and I try to get the XML file to parse in PHP, I only get the last line (i.e. the text after the last new line)

How can I get around this…

my XML file looks like the following

```php

<HOME>
	<MAINTEXT>First Line
Another Line</MAINTEXT>
	<NEWS>
	</NEWS>
</HOME>

```

but php just reads “Another Line”

Please help  
-Aditya

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 12, 2003, 5:24pm UTC](https://forum.kirupa.com/t/new-lines-in-xml-files/25423/2 "2003-07-12T17:24:17Z")

</div>

well… u admin guys can close this topic if u want… I figured the thing out. But for those who may need the same info. All you need to do is when writing the XML file, replace all instances of "  
" with some fake newline character like “-nl-”. Then when readin it you can replace all instances of “-nl-” with "  
". And it works!

-Aditya  
:thumb:
