472,955 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,955 software developers and data experts.

Insert data from XML to MYSQL

Hi, I will like to know if you know how to do it. I have this code for
read google news and I want to added to my DB MYSQL so I can store the
news for reading went I want.

Here is the code I use for read the news.

<?
//include "lang.php";
include "funciones.php";
echo <<<EOT
<center>
<h3><strong>SPANISH NEWS</strong></h3>
<table width="100%" align=center style="border:0px solid #aa0033;
font-size:small">
<tr>
<td width="3" rowspan=3> <div align="center">&nbsp;<a
href=index.php?action=weather><img
src="http://www.inm.es/wwb/predi/p01gesp1.jpg" height=90 width=150
alt="Weather"><br><center>
<font color="#000000" size="2"><strong>The
Weather</a></strong></font></center> </div></td>
<td colspan=2 align=center><b>Subscribe for free to
Fuerteventura<br>
News</b></td>
</tr>
<form action="add_email.php">
<tr>
<td width="232"><div align="center">Email:
<input type=text name=email>
</div></td>
<td width="3"> </td>
</tr>
</form>
<tr>
<td height="26" colspan=2 align=center> <div align="center">
<input type=submit name="sub" value="Subscribe">
</div></td>
</tr>
</table>
</center>
EOT;
$url = "/news?hl=en&ned=us&q=spain&ie=UTF-8&output=rss";
$xml_parser = xml_parser_create();

$rss_parser = new RSS_1_0_Parser();

xml_set_object($xml_parser,&$rss_parser);

xml_set_element_handler($xml_parser, "startElement", "endElement");

xml_set_character_data_handler($xml_parser, "characterData");

$file = new GetWebObject("news.google.com", 80, $url);
$datas = $file->get_header();

//echo $datas["status"];
//echo $datas["Content-Type"];
$xml_declaration = "<?xml version=\"1.0\" ?>";
$fp = $file->get_content();
$new_contents="";
$xml_declaration_count = substr_count(Substr($fp,0,10),"<?xml");
if($xml_declaration_count == "0")
{
$new_contents = $xml_declaration . $fp ;
}
else
{
$new_contents = $fp;
}
if (!xml_parse($xml_parser, $new_contents ) )
{
//echo($fp);
die(sprintf("Unable to parse : XML error: %s at line
%d",xml_error_string(xml_get_error_code($xml_parse r)),
xml_get_current_line_number($xml_parser)));
}

xml_parser_free($xml_parser);
echo <<<EOT
<table width="100%" border="0">
<tr>
<td><div align="center">
<p><font size="2">Linking to <a
href="http://www.fuerteventuranews.com">Fuerteventuranews.com</a>.
<br>
Many sites are happy to link to us because <br>
we provide a comprehensive source of<br>
information about Fuerteventura. If you wish <br>
to link to the site, then add this code to your HTML
code.<br>
<textarea name="textarea" cols="50" rows="3"><a
href="http://www.fuerteventuranews.com">Fuerteventura, News Guide,
Information, Travels and Places to visit
http://www.fuerteventuranews.com</a>
</textarea>
</font> </p>
</div></td>
</tr>
</table>

EOT;

?>

How Can I save this to my DB??

THANKS TO ALL!!

Feb 17 '06 #1
0 2564

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great...
2
by: Atz | last post by:
Hi to all ! Im using MySql front and PHP 5 for some web shop. I didn't try it so far but i guess that the online data insertation ( accept costs and time ) should be the same process like for...
2
by: Tavish Muldoon | last post by:
What a pain trying to insert data into a table from a stored proc. My webform asks for 16 pieces of data - which then gets written to the database. I found this easier than the crap below...
10
by: Python_it | last post by:
Python 2.4 MySQL-python.exe-1.2.0.win32-py2.4.zip How can I insert a NULL value in a table (MySQL-database). I can't set a var to NULL? Or is there a other possibility? My var must be variable...
3
by: kristof.loots | last post by:
Hi all, Somehow I want to transfer data from an mysql database on the web to an local offline access database. Note: tables and types do not match. So, I toughed, generating sql commands to...
1
by: Joe | last post by:
Hello All, I am trying to insert a record in the MS Access DB and for some reason I cannot get rid of error message, System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. ...
2
by: bballr | last post by:
I have a problem that I'm not sure if it can be done. I'm trying to use the MySQL C API to be able to use a normal sql insert statement that will send the data or file to a directory and NOT the...
2
josie23
by: josie23 | last post by:
Egad, I'm not a coder/programmer by nature or occupation but understand things like html and css and a small amount of perl. So, basically, I'm a perl/mysql imbecile. But, I've been trying to...
6
by: TheRealDan | last post by:
Hi all. I'm having a problem with a special characters. I have php script that reads from an xml file and writes to a mysql db. It's a script called phptunest that I found on the net, although the...
0
by: brianrpsgt1 | last post by:
I am attempting to insert data from a HTML form using a .psp script. I can not find how to link the data that is inserted into the form to the variables in the .psp script to then insert into the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.