harchew Posted January 4, 2008 Share Posted January 4, 2008 Currently working on php and xml This is my xml format : <?xml version="1.0"?> <data> <event> <content> The pre element defines preformatted text. The text enclosed in the pre element usually preserves spaces and line breaks. The text renders in a fixed-pitch font.The pre element defines preformatted text. The text enclosed in the pre element usually preserves spaces and line breaks. The text renders in a fixed-pitch font.<BR><strong>Text to be bold</strong></BR> </content> </event> </data> I am using the following code to display the data : <?php $file = @file_get_contents("myxml file name"); if($file) { $xmlFileData = file_get_contents("myxml file name"); $xmlData = new SimpleXMLElement($xmlFileData); foreach($xmlData->event as $event) { echo $event->content; } } ?> Its able to display some portion of the content. however the script will stop displaying the rest of the content after the <BR> symbol. So is there any wrong with my php coding? I need to display all the content without removing the text format. is there any solution out there... thank you in advance... Link to comment https://forums.phpfreaks.com/topic/84419-php-and-xml/ Share on other sites More sharing options...
awpti Posted January 4, 2008 Share Posted January 4, 2008 I seem to recall the need for ![CDATA[ The content <br /> <strong>blah</strong>]] Otherwise it's treated as part of the XML document. EX: <?xml version="1.0"?> <data> <event> <content> ![CDATA[The pre element defines preformatted text. The text enclosed in the pre element usually preserves spaces and line breaks. The text renders in a fixed-pitch font.The pre element defines preformatted text. The text enclosed in the pre element usually preserves spaces and line breaks. The text renders in a fixed-pitch font.<BR><strong>Text to be bold</strong></BR>]] </content> </event> </data> (As an aside.. </br>?) Link to comment https://forums.phpfreaks.com/topic/84419-php-and-xml/#findComment-430023 Share on other sites More sharing options...
harchew Posted January 4, 2008 Author Share Posted January 4, 2008 wow thank u so much. solve my problem effortlessly... this is the edited code i used <![CDATA[ content ]]> Link to comment https://forums.phpfreaks.com/topic/84419-php-and-xml/#findComment-430038 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.