Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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

Posts: 38
Location: Sweden
Trades: 0
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
 
 
Register now for full access!
Old 05-07-2008, 07:55 PM Re: XML and PHP
addonchat's Avatar
Super Talker

Posts: 115
Name: Chris Duerr
Trades: 0
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

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
addonchat is offline
Reply With Quote
View Public Profile
 
Old 05-07-2008, 11:02 PM Re: XML and PHP
Average Talker

Posts: 15
Name: Mark
Trades: 0
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
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Datingsoftware is offline
Reply With Quote
View Public Profile
 
Old 05-07-2008, 11:12 PM Re: XML and PHP
Plugin-Developer's Avatar
Weightlifting CS Student

Posts: 504
Name: Nick Ohrn
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE
- Custom plugin development to fit your needs. Plugins available for WordPress and Drupal, among others.
Plugin-Developer is offline
Reply With Quote
View Public Profile Visit Plugin-Developer's homepage!
 
Old 05-08-2008, 04:06 AM Re: XML and PHP
Tulork's Avatar
Experienced Talker

Posts: 38
Location: Sweden
Trades: 0
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, 04:21 AM Re: XML and PHP
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
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 -->
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 05-08-2008 at 04:26 AM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to XML and PHP
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.22888 seconds with 12 queries