TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   PHP and XML? (http://www.talkphp.com/general/2557-php-xml.html)

Aaron 03-31-2008 02:57 AM

PHP and XML?
 
I was just thinking about it, and... How can you form a page while "separating data from presentation"? Marking up a piece of data just for presentational purposes (in XML) is the same as using a tag like <sup> in HTML, yet the latter is frowned upon.

Anyway my question is: Can you use PHP in an XML file, or XML in a php file? How exactly would that work out...

abiko 03-31-2008 08:39 AM

Well.
Simple usage of XML is - you read data from it, you can structure it how you like.

For using php in XML file - sure - but you must use eval() for that code to be executed.
XML in a PHP file - XML must be in a string
PHP Code:

<?php
 $xml 
"
<?xml version="
1.0" encoding="utf-8"?>
<books>
 <bookInfo>
    <id>12</id>
    <name>The Test Name Of A Book</name>
    <price>18,45</price>
  </bookInfo>
</books>
"
;
?>

Parsing in now real easy using the PHP5s DOM or XPath.

Can you provide more detailed question :) Hope this cleared some things.


All times are GMT. The time now is 12:27 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0