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

  • SEARCH
  • Home
  • 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 670185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:14:05+00:00 2026-05-14T00:14:05+00:00

I am trying to make an xml file to export my data from my

  • 0

I am trying to make an xml file to export my data from my database to my iphone. Each time I create a new post, I need to execute a php file to create a xml file containing the latest post 😉

Okay so far ? 😀

Here is current php code … but my nsxmlparser gives me an error code (33 – String is not started). I have no idea what kind of php functions I have to use …

<?php

// Èdition du dÈbut du fichier XML
$xml .= '<?xml version=\"1.0\" encoding=\"UTF-8\"?>';
$sml .= '<channel>'; 
$xml .= '<title>Infonul</title>';
$xml .= '<link>aaa</link>';
$xml .= '<description>aaa</description>';


// connexion a la base (mettre ‡ jour le mdp)
$connect = mysql_connect('...-12','...','...');


/* selection de la base de donnÈe mysql */
mysql_select_db('...');


// selection des 20 derniËres news
$res=mysql_query("SELECT u.display_name as author,p.post_date as date,p.comment_count as commentCount, p.post_content as content,p.post_title as title FROM wp_posts p, wp_users u WHERE p.post_status = 'publish' and p.post_type = 'post' and p.post_author = u.id ORDER BY p.id DESC LIMIT 0,20");




// extraction des informations et ajout au contenu
while($tab=mysql_fetch_array($res)){   

 $title=$tab[title];
 $author=$tab[author];
 $content=$tab[content]; //html stuff
 $commentCount=$tab[commentCount];
 $date=$tab[date];

 $xml .= '<item>';
 $xml .= '<title>'.$title.'</title>';
 $xml .= '<content><![CDATA['.$content.']]></content>';
 $xml .= '<date>'.$date.'</date>';
 $xml .= '<author>'.$author.'</author>';
 $xml .= '<commentCount>'.$commentCount.'</commentCount>';
 $xml .= '</item>'; 
}

// Èdition de la fin du fichier XML
$xml .= '</channel>';
$xml = utf8_encode($xml);

echo $xml;

// Ècriture dans le fichier
if ($fp = fopen("20news.xml",'w'))
{
 fputs($fp,$xml);
 fclose($fp);
}

//mysql_close();

?>

I noticed a few things when i open 20news.xml in my browser :

  • I got squares instead of single quotes …
  • I can’t see <[CDATA[ but ]]> is clearly visible … why ?!?

Thanks for any input 😉

Gotye.

  • 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-05-14T00:14:05+00:00Added an answer on May 14, 2026 at 12:14 am

    Maybe you should use an XML library, e.g. php’s DOM API, instead of string concatenation. Saves a lot of headaches.

    Moreover, XML files need a single root element that contains all the other elements in order to be well-formed (see Wikipedia).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make dynamic menu using xml data, I'm creating that menu using
I'm trying to make a dynamic image gallery from and xml. From my tutorials,
I'm trying to make a url in an XML file show up on an
So i am trying to make a function that searches trough an xml file,
I'm getting mad trying to create an XML schema to transform an Excel file
I am trying to send a SOAP request from a xml file and send
I am trying to setText() to a TextView resource from a layout XML file.
I am new to Sencha Touch framework. I need to load some data from
I'm trying to process an imported XML file and make the text in one
I'm currently trying to read in an XML file, make some minor changes (alter

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.