473,834 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using PHP & MySQL to Input XML data to database!

1 New Member
Hi guys,

I need help. I am trying to extract data from XML file. I am using all the fucntions needed to parse the xml data every thing working fine, but what I am looking for is to take the string data in each element and enter it to database. for example

I have the following xml file "sitecontent.xm l" .
--------------------------
<?xml version="1.0" encoding="UTF-8" ?>
- <content>
<link>http://www.web.com</link>
<title>Title name </title>
<description>Th is line will be description bla bla </description>
<keywords>Thi s line will be all data ..............e tc </keywords>
</content>
-------------------------
and my PHP code will be like this

----------------------
<?php
include ('dbconnet.php' );
$parser=xml_par ser_create();
xml_set_element _handler($parse r,"start","stop ");
xml_set_charact er_data_handler ($parser,"char" );
$fp=fopen("site content.xml","r ");
while ($data=fread($f p,4096))
{
xml_parse($pars er,$data,feof($ fp)) or
die (sprintf("XML Error: %s at line %d",
xml_error_strin g(xml_get_error _code($parser)) ,
xml_get_current _line_number($p arser)));
}
function start($parser,$ element_name, $attribs)
{
switch($element _name)
{
case "CONTENT":
echo "<p>-- CONTENT --</p><br/>";
break;
case "LINK":
echo "<B>Link:</B> ";
break;
case "TITLE":
echo "<B>Title:</B> ";
break;
case "DESCRIPTIO N":
echo "<B>Description :</B> ";
break;
case "KEYWORDS":
echo "<B>Keyword s:</B> ";
Break;
}
}
function stop($parser,$e lement_name)
{
echo "<br /><br />";
}
function char($parser,$d ata)
{
echo $data;
}
xml_parser_free ($parser);
----------------------------
The output is like this

-- CONTENT --


Link: http://www.web.com

Title: Title name

Description: This line will be description bla bla

Keywords: This line will be all data ..............e tc


---------------
What I need to do is take link content which it is http://www.web.com insert it to my table where field name = link
same thing with the other "Title name " to field name Title , "This line will be descritoption bla bla " to discription filed and so on.

If you know any way of tools to do that I will be greaty apritiated.

Balean
Aug 1 '07 #1
0 1326

Sign in to post your reply or Sign up for a free account.

Similar topics

3
15467
by: James | last post by:
HI, I'm looking for a script that will allow users/admins to have a one click backup solution for a MYSQL Database.. 'BACK DATABASE' button, click and its done... The a restore option, that shows all current backups, and restores the selected one with one click...
7
3367
by: AF | last post by:
I am a real novice to php and MySQL, with about a week's worth of reading and self tutoring. I have an urgent need to publish a database of information and need some guidance on how to do this. This question might be more suited to a MySQL newsgroup, but since php and MySQL seem to have become almost married to one another, and since getting the data out and displaying it is where my problem seems to lie, I thought I would start with...
2
3455
by: Sam White | last post by:
I have set up a MySQL db on one server, IIS 6.0 on another. Using Frontpage I created some forms to input data. On a test page I made, I have 4 fields. First is the ID which is autonumber (I leave alone). The second is marked as TEXT, the third is MEDIUMTEXT, and the fourth is DATE. This is just an example though, the problem exists in no matter what manner I create the form. Now here is the issue. In the TEXT fields nothing is saved...
4
1575
by: cover | last post by:
I have two distinctively different pieces of equipment that I'm trying to build a database for, each having 20 inputs which makes my mysql table 40 fields wide. Form one is for 'shakers' and form two is for 'conveyors'. About the only thing they will have in common is that they both share 'motorsize' and they both share 'bearing' although shakers have two where conveyors have four. I'd first built a table within a database called...
2
3013
by: PHP_Paul | last post by:
Ok, I'm trying to poineer into the wonderful area of PHP/MySQL programming, but I'm having some difficulties. http://www.paulhq.com/php/freepage.html should register, but when anyone fills something out, it returns a MySQL error: Could not insert data because You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 Here are the codes: freepage.html...
3
11847
by: elyob | last post by:
Okay, I'm about to add some checkboxes to a form, and then store the data in a column on a MySQL database. Just wanted to know best practice, at the moment I'm writing and thinking .. God that's ungly code ... <input type="checkbox" name="delta" <?php if ($delta==1) { echo "checked"; }?>> Delta<br> <input type="checkbox" name="mastercard" <?php if ($mastercard==1) { echo "checked"; }?>> Mastercard<br> <input type="checkbox" name="solo"...
221
367805
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application needs to store entire files, the preferred method is to save the file onto the server’s file-system, and store the physical location of the file in your database. This is generally considered to be the easiest and fastest way to store files. ...
1
4369
George Lft
by: George Lft | last post by:
ok, first of all, i built my register page using dreamweaver tool which the codes haven been out of control. Now i'm thinking that turning over everything - by using this another set of codes. And these new sets of codes have overwhelmed me a bit. Here's the new code: CREATE TABLE `users` ( `ID` int(11) NOT NULL auto_increment, `Username` varchar(255) NOT NULL, `Password` varchar(255) NOT NULL, `Temp_pass` varchar(55)...
6
2998
by: dkyadav80 | last post by:
Hi guys, I have a form in html , all description below: first: name of persion (input type box) second: job profile (input type box) third: experience from: list box (Month : Jan, Feb,.. format) and experience to: list box (year: 2008,2007,2006,...) In Mysql database only 4 filed, 1. Name(data type - varchar),
0
9796
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10503
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10544
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9326
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7754
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5624
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5790
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.