tags:

views:

162

answers:

2

Ive been trying to display formatted content blocks from a xml file with no luck. Ive been using simplexml_load_file and other varients which Im now seeing cannot deal with the xhtml tags within the called tag ... eg.

//php contents
 <?php $xml=simplexml_load_file("file.xml");
 echo ($xml->entry); ?>


//xml contents
 <entry>
 <p>This does not work</p>
 </entry>

whereas

 <entry>This works</entry>

can someone please tell me which php function can do this from an xml file and or what is the best way to display the contents with xhtml formatting?

Im trying to dynamically load content to a webpage without having to build too many pages. I like the idea of having all my content in one xml file for easy edits.

Theres not enough content to justify a database yet.

Thanks in advance

+1  A: 

im getting closer... I found asXML() which outputs the html tags... but not sure yet how to point to specific blocks.... eg $xml->asXML(block) displays 1

got it

$xml->block->asXML()

works

would still like to know if there is a better method tho.

chris
+2  A: 

You can try dumping the contents of a certain simplexml node (in this case: $xml->entry) using the asXml function.

echo $xml->entry->asXml();

Check the php documentation on simplexml here (link to the asXml() call):

Simplexml documentation

Brett Bender
ha found the solution then saw your response... thanks
chris