php making xml (rss/rdf)

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
kaizix
Forum Commoner
Posts: 50
Joined: Tue Jun 18, 2002 9:16 pm
Location: california
Contact:

php making xml (rss/rdf)

Post by kaizix »

i'm trying to make php output a xml (rss/rdf) file....i don't want it to parse it but rather, to write it...is there a way i can? i haven't figured out how to make it work....are there special functions i need to use? can anyone help?
MattF
Forum Contributor
Posts: 225
Joined: Sun May 19, 2002 9:58 am
Location: Sussex, UK

Post by MattF »

If you want to just create a XML page it is very simple, I have a page that dumps a database table to XML, here is the code:

Code: Select all

<?php
header('Content-type: text/xml');
echo "<?xml version="1.0"?>\n";                 
echo "<content>\n\n";
$r = mysql_query("SELECT * FROM " . $tbl&#1111;'content']);
while($q = mysql_fetch_array($r,MYSQL_ASSOC))
&#123;                                                 
    echo "<article>\n";
    foreach($q as $tag => $value)
    &#123;                                             
        $value= htmlspecialchars($value);         
        echo "<$tag>$value</$tag>\n";
    &#125;                                             
    echo "</article>\n\n";
&#125;                                                 
echo "\n\n</content>";
?>
kaizix
Forum Commoner
Posts: 50
Joined: Tue Jun 18, 2002 9:16 pm
Location: california
Contact:

Post by kaizix »

ah, that's what i was missing...the header description.....thanks a bunch.
Guest

XMl/XSL parsing

Post by Guest »

Hi,

I am new to PHP with XMl/XSL. Care to tell me how I can parse a XML page instead?

I have tries searching and reading the PHP helpfiles but still cannot understand and find a solution.

Please help. Thanks in advance.
[/list]
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

look this

Post by AVATAr »

look this example, it uses xml parser

http://www.phpbuilder.com/columns/joe20000907.php3
Post Reply