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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.