Reply
XML and PHP
Old 05-07-2008, 04:24 PM XML and PHP
Tulork's Avatar
Experienced Talker

Posts: 32
Location: Sweden
I have a questing regarding PHP and XML. Whats the best way for working with php and xml in the sense of presenting values from the database via PHP to the different xml files. The XML files are then used by flash to generate grafic and so on, based on the values in the xml files.
__________________
Hurray for me (not)
Tulork is offline
Reply With Quote
View Public Profile
 
Sponsored Links (We share ad revenue):
 
Old 05-07-2008, 06:55 PM Re: XML and PHP
addonchat's Avatar
Skilled Talker

Posts: 97
Name: Chris Duerr
Typically, I would just read a record in from the database, perhaps store it in an object, and call an object function to spit out the XML code manually to suit your DTD spec -- either to display or a file.

Parsing XML is usually where people will need help with pre-built functions/classes. http://www.php.net/xml for that.
__________________
Chris Duerr
AddonChat Java Chat Software
http://www.addonchat.com/ - Affiliate Program
addonchat is offline
Reply With Quote
View Public Profile
 
Old 05-07-2008, 10:02 PM Re: XML and PHP
Average Talker

Posts: 15
Name: Mark
something like this is works well;

PHP Code:
 //// YOUR DATABASE CONNECTION AND DATA HERE ///
header("Content-type: text/xml"); 
print '<?xml version="1.0" encoding="utf-8"?>
<CONFIG>
    <SETTINGS>
        <PLAYER_SETTINGS Name="name" Value="valu"/>     
    </SETTINGS>
</CONFIG>';
easy
Datingsoftware is offline
Reply With Quote
View Public Profile
 
Old 05-07-2008, 10:12 PM Re: XML and PHP
nickohrn's Avatar
Weightlifting CS Student

Posts: 480
Name: Nick Ohrn
If you're using PHP5, I would investigate using the DomDocument class for building up your XML document. Also, are you only going to be using the data in the database for this purpose? If so, why not just store the data as XML in the first place.
__________________
NickOhrn.com - My personal haven of insight to offer the world.
Plugin-Developer.com - Custom plugin development to fit your needs. Plugins available for WordPress and Drupal, among others.
nickohrn is online now
Reply With Quote
View Public Profile Visit nickohrn's homepage!
 
Old 05-08-2008, 03:06 AM Re: XML and PHP
Tulork's Avatar
Experienced Talker

Posts: 32
Location: Sweden
The xml documents will contain different values for different users... they have to be dynamic... the structure of the xml files will be the same in all of them though. With Dom, doesnt that just create files over and over again? Either overwrightes the old file, or creates a new one? I probably wrong.
__________________
Hurray for me (not)
Tulork is offline
Reply With Quote
View Public Profile
 
Old 05-08-2008, 03:21 AM Re: XML and PHP
tripy's Avatar
Fetchez la vache!

Latest Blog Post:
Pretty pretty please….
Posts: 1,689
Name: Thierry
Location: In the void
I personaly like the phpWriter extension.
I've used it in my framework quixml [ http://www.quixml.org ]

I end up the XML generation with something like this:
PHP Code:
$objXml->setRendering('html');
$objXml->setXsl('org.quixml.index');
$objXml->start();
   
$objXml->open('DATAS');
      
$objXml->att('demo','true');
      
$objXml->data('feeling','Happy');
      
$objXml->open('subcat');
        
$objXml->data('test','data comes here');
      
$objXml->close();
   
$objXml->close();
$objXml->end();

$objXml->output(); 
which output something like that:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML>
<?xml-stylesheet href="/xsl/org.quixml.index" type="text/xsl"?>
<ROOT>
 <DATAS demo="true">
  <feeling>happy</feeling>
  <subcat>
    <test>data comes here</data>
  </subcat>
 </DATAS>
</ROOT>
<!-- Generation time: 0.00999999046326 -->
__________________
Listen to the ducky: "This is awesome!!!"


Last edited by tripy : 05-08-2008 at 03:26 AM.
tripy is online now
Reply With Quote
View Public Profile
 
Sponsored Links (We share ad revenue):
 
Reply     « Reply to XML and PHP
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML


Page generated in 0.37957 seconds with 14 queries