Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to print well formated xml on php call

Status
Not open for further replies.

rammi07

Programmer
Aug 1, 2006
20
0
0
NL
Hi all i got a php script that pulls xml file from remote server and writes it to a file and also displays it browser.The porblem is that the echo does not produced well formated xml!!(Note:the writeen file is well formated but not output to browser). when i call this php i want to be able to use its content but since it is not formated i can not use it. I be happy if some one show me how i can output well formated xml .Thanks



<?php

$xml_data = file_get_contents("
echo $xml_data;

$file = fopen("./myfile.xml", "w");
fwrite($file, $xml_data);
fclose($file);


?>
 
if you are talking about outputting to the screen then this looks ok

Code:
<?php
$xml_data = file_get_contents("[URL unfurl="true"]http://www.radiojavan.com/rss.php?xml=true&amp;count=10");[/URL] 

echo "<pre>" . htmlentities($xml_data) ."</pre>";

?>

if you are talking about vertical formatting and tab indenting, I can't see any in the original input so you would have to write a parser to fix it manually or use a xml style sheet transformation or similar.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top