I've created php pages to get info and send it to my xml. Then created pages to view the information but it looses the formatting somewhere in the process. How do I keep my formatting?
I've created php pages to get info and send it to my xml. Then created pages to view the information but it looses the formatting somewhere in the process. How do I keep my formatting?
From that little info, it's really hard to tell.
What is formatting? HTML markup?
Perhaps the HTML is getting parsed as XML.
You should escape it before saving it and unescape it when loading it.
> becomes &gr; becomes >, and so forth.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
The formating looks correct in my xml file.
each line ends with a(I had to use dots between the items cause it kept disapearing...so remove the dots)Code:&.#.1.3.;
isn't that the code for the end of a line?
On the page I only want to show the last message (if they want to see others they will need to go to another page to view old items) so I use the following code. I even ripped the code and used it in on an otherwise empty page to make sure none of my other code is screwing with it...yet, I get the same results. All the text runs together like one big paragraph.
<body>
<?php
$file = 'xml/messages.xml';
$xml = simplexml_load_file($file);
$i = count($xml_>messages)-1;
for($x=$i;$x>=0;$x--)
{
echo
$xml->messages[$x]->title.'<br />'
$xml->messages[$x]->author.'<br />'
$xml->messages[$x]->message;
break;
}
?>
Last edited by I am Abby; 05-18-2010 at 08:25 PM. Reason: missing code
Found the solution to the problem. nl2br()
all I did was change
intoCode:<body> <?php $file = 'xml/messages.xml'; $xml = simplexml_load_file($file); $i = count($xml_>messages)-1; for($x=$i;$x>=0;$x--) { echo $xml->messages[$x]->title.'<br />' $xml->messages[$x]->author.'<br />' $xml->messages[$x]->message; break; } ?>
Code:<body> <?php $file = 'xml/messages.xml'; $xml = simplexml_load_file($file); $i = count($xml_>messages)-1; for($x=$i;$x>=0;$x--) { echo nl2br(' .$xml->messages[$x]->title.'<br />' $xml->messages[$x]->author.'<br />' $xml->messages[$x]->message, false ) } ?>
Bookmarks