删除XML字符串中的返回

With simplexml_load_file... I've loaded an xml file. Now I want to process this file with javascript, so I created a string of it's content. Unfortunatly this string contains some returns so it can't be read. How can I get rid of these returns.

// this doesn't work because the return is not shown in the code, it just starts at a new line    
str_replace('
','',$string);

I put in the xml as follows:

<?php
$results = simplexml_load_file('file.xml');
$resultsAsString = $results->asXML();
?>
//---
<script>    
    var xml = '<?= $resultsAsString; ?>';
</script>

And when I view the source it looks like this:

var xml = '<?xmlversion="1.0"?>
<element></element>
';

How do I remove the return after "?>" and after "/element>"

Don't forget that is another use of a newline character. Try something like this:

<?
$resultsAsString = '<?xml version="1.0"?>
<element></element>
';
$singleLine = str_replace(array("
", ""), "", $resultsAsString);
?>
<script>
    var xml = '<?=($singleLine);?>';
</script>

Edit: If you're looking to parse through the XML, may I suggest a look at this answer as well:

Cross-Browser Javascript XML Parsing