Jump to content

Working with XML and PHP


George Botley

Recommended Posts

I am developing a CMS to make Samsung's Digital Display management even easier for a school making use of them.

 

 

But, one part of the screen uses a slideshow that grabs images from an XML fed file. Here is a snipped of said file.

 

 

<slide>
      <url><![CDATA[3.jpg]]></url>
      <description>
        <heading>Image Three Title</heading>
        <paragraph>Image Three description taken from database to appear here.</paragraph>
      </description>
    </slide>

 

 

How would I use PHP to make the document think itself as XML whilst still being able to populate these tags with MySQL fetched data.

 

 

I.e.

 

 

<paragraph><? echo "This was taken: Monday...."; ?></paragraph>

 

 

Any ideas? - Thanks in advance.

 

 

George.

Link to comment
Share on other sites

Why does this one not work?

 

 

 


<? 


echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";


?>


<data>
  <debug>0</debug>
  <settings>
  
    <folder_images>images</folder_images>
<folder_fonts>fonts</folder_fonts>

    <background>
      <color transparent="true"><? echo "$color"; ?></color>
    </background>


  </settings>
</data>

Link to comment
Share on other sites

It technically works for me...

<?xml version="1.0" encoding="ISO-8859-1" ?>
<data>
  <debug>0</debug>
  <settings>
    <folder_images>images</folder_images>
<folder_fonts>fonts</folder_fonts>
    <background>
      <color transparent="true">yellow</color>
    </background>
  </settings>
</data>

Link to comment
Share on other sites

I see what you mean.

 

Does this work?

It won't load into my directly into my browser. As is it ask me where to save, by commenting out some parameters it'll ask what I want to open it with (and it works with my browsers)...

 

<?php
function dumip_it($s,$fn="fn.xml"){
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$fn);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: '.strlen($s));
ob_clean();
ob_flush();
print $s;
exit;
}
$s="<?xml version='1.0' encoding='ISO-8859-1' ?>
<data>
  <debug>0</debug>
  <settings>
    <folder_images>images</folder_images>
<folder_fonts>fonts</folder_fonts>
    <background>
      <color transparent='true'>yellow</color>
    </background>
  </settings>
</data>";
dumip_it($s);
?>

 

other...

header('Content-Description: File Transfer');
//header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$fn);
//header('Content-Transfer-Encoding: binary');
//header('Expires: 0');
//header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
//header('Pragma: public');
header('Content-Length: '.strlen($s));

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.