Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9024745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:06:06+00:00 2026-06-16T06:06:06+00:00

I have a problem in XML files. I searched through the internet and found

  • 0

I have a problem in XML files.
I searched through the internet and found lots of examples for my problem but I am not an expert on XML files and couldn’t solve my problem. I want to do and XML file and work like RSS FEED. So, I am taking my data from my database and try to create the xml-code. Here what I have in my php file
(and it is not validated because of this problem: Undefined root element: channel)

<?php
include "connection.php";
//create the table with the fields
  $rss_table = array(); 
  $query = mysql_query("SELECT * FROM rssfeeds");
    while($values_query = mysql_fetch_assoc($query))
    {
        $rss_table [] = array(
        'title' => $values_query['title'],
        'description' => $values_query['summary'],
        'link' => $values_query['link']
        );
    }

$doc = new DOMDocument(); 
$doc->formatOutput = true;
$doc->encoding = "utf-8";

$r = $doc->createElement( "channel" ); 
$doc->appendChild( $r ); 

   //$i=0;
    foreach( $rss_table as $rss ) 
    { 
    $b = $doc->createElement( "item" );
        $title = $doc->createElement( "title" ); 
        $title->appendChild( 
        $doc->createTextNode( $rss['title'] ) 
        ); 
    $b->appendChild( $title ); 


    $description = $doc->createElement( "description" ); 
    $description->appendChild( 
    $doc->createTextNode( $rss['description'] ) 
    ); 
    $b->appendChild( $description );

    $link = $doc->createElement( "link" ); 
    $link->appendChild( 
    $doc->createTextNode( $rss['link'] ) 
    ); 
    $b->appendChild( $link );

    $r->appendChild( $b );
    }
echo $doc->saveXML();
$doc->save("rssfeeds.xml") 
?>

I want to have title – link – description
Simple one… nothing more

And here is what I get in rssfeeds.xml file:

<?xml version="1.0" encoding="utf-8"?>
<channel>
  <item>
    <title>winter week</title>
    <description>You can come as you are! </description>
    <link>http://tdm2000international.org/tdm2000international/news.php</link>
  </item>
  <item>
    <title>Greek night</title>
    <description>elliniki bradua sto magazi</description>
    <link>http://tdm2000international.org/tdm2000international/news.php</link>
  </item>
  <item>
    <title>event website</title>
    <description>first of december, how is it going?</description>
    <link>http://tdm2000international.org/tdm2000international/news.php</link>
  </item>
</channel>

Nice format, but it has problem. I do not understand where the problem is.
Any help would be appreciated

(I also check this website for any solution, but I could not found my solution..So, sorry about this post, if it is already exist)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T06:06:07+00:00Added an answer on June 16, 2026 at 6:06 am

    ok I found my one way .. I did it with FILES via php: this is the code if anyone needs help to that:

    <?php
    include "connection.php";
    $myFile = "rss.xml";
    $fh = fopen($myFile, 'w') or die("can't open file");
    
    $rss_txt .= '<?xml version="1.0" encoding="utf-8"?>';
    $rss_txt .= "<rss version='2.0'>";
    $rss_txt .= '<channel>';
        $query = mysql_query("SELECT * FROM rssfeeds");
        while($values_query = mysql_fetch_assoc($query))
        {
            $rss_txt .= '<item>';
    
            $rss_txt .= '<title>' .$values_query['title']. '</title>';
            $rss_txt .= '<link>' .$values_query['link']. '</link>';
            $rss_txt .= '<description>' .$values_query['summary']. '</description>';
    
            $rss_txt .= '</item>';
        }
    $rss_txt .= '</channel>';
    $rss_txt .= '</rss>';
    
    fwrite($fh, $rss_txt);
    fclose($fh);
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has anyone had this problem? My projects tend to have some long XML files
I've the problem: I have to serialize class to XML file. But two properties
I have a problem reading OWL/XML files from Java using Jena. I have no
I have problem merging two XML files. I loaded both files into two objects,
I have searched all around to find a solution to my problem, but i
I have a problem with deserialization of my xml files. Let's pretend that we
I have a problem with my webservice! As I render xml files just like
Problem : I have dozen of xml files in amount between 1 to 5
I have a problem parsing a XML file which contains special characters like ,
I have a problem with using the SAX parser to parse a XML file.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.