Jump to content

Php And XML


harchew

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.