473,320 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 2590

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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.