473,544 Members | 1,024 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML datas to MySQL database

Where to find a comprehensive document on how take datas from XML and put
them in a Mysql Database.
I've many sites sending us XML files. We have to parse datas and save those
datas on Mysql.

The problem is that we have many different file format (each company sends
us it's own XML structure).

How to provide a simple way to get those datas in Mysql, without having to
create a new PHP script for every new site's XML ?

Please help.

Bob
Jul 18 '05 #1
9 2212
Bob Bedford wrote:
Where to find a comprehensive document on how take datas from XML and
put them in a Mysql Database.
I've many sites sending us XML files. We have to parse datas and save
those datas on Mysql.

The problem is that we have many different file format (each company
sends us it's own XML structure).

How to provide a simple way to get those datas in Mysql, without having
to create a new PHP script for every new site's XML ?

Please help.

Bob


Bob,

If the XML formats are widely different, you'll probably have to create
different PHP scripts for each one.

The alternative is to build one huge script which would handle all possible
formats. However, that quickly becomes very difficult to manage. If any of the
companies changes their XML format, you'd have to worry about the changes to
your huge script would affect everyone else.

Sometimes it's just simpler to handle different things in different scripts.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jul 18 '05 #2
"Jerry Stuckle" <js*******@attg lobal.net> a écrit dans le message de news:
7f************* *******@comcast .com...
Bob Bedford wrote:
Where to find a comprehensive document on how take datas from XML and put
them in a Mysql Database.
I've many sites sending us XML files. We have to parse datas and save
those datas on Mysql.

The problem is that we have many different file format (each company
sends us it's own XML structure).

How to provide a simple way to get those datas in Mysql, without having
to create a new PHP script for every new site's XML ?

Please help.

Bob


Bob,

If the XML formats are widely different, you'll probably have to create
different PHP scripts for each one.

The alternative is to build one huge script which would handle all
possible formats. However, that quickly becomes very difficult to manage.
If any of the companies changes their XML format, you'd have to worry
about the changes to your huge script would affect everyone else.

Sometimes it's just simpler to handle different things in different
scripts.

Thanks for the advice.
Anyway for my first scripts I had to manage everything manually. Its' there
any class or code that takes out all datas from a XML and put it in a
simpler structure ? maybe an array, that let me create a simpler script ?

Bob
Jul 18 '05 #3
Bob Bedford wrote:

Thanks for the advice.
Anyway for my first scripts I had to manage everything manually. Its'
there any class or code that takes out all datas from a XML and put it
in a simpler structure ? maybe an array, that let me create a simpler
script ?


Hi Bob,

You could use a dtd parser and then dynamically create a mysql table
with that particular structure. Then after that you can put the data
from the xml files in the right mysql table which belongs to its dtd.
You'd get a column for each xml element. Handling nested xml data would
be a little tougher though.

--
http://www.phpforums.nl
Jul 18 '05 #4

"Peter van Schie" <va************ @gmail.com> a écrit dans le message de
news: 42************* **********@news .wanadoo.nl...
Bob Bedford wrote:

Thanks for the advice.
Anyway for my first scripts I had to manage everything manually. Its'
there any class or code that takes out all datas from a XML and put it in
a simpler structure ? maybe an array, that let me create a simpler script
?


Hi Bob,

You could use a dtd parser and then dynamically create a mysql table with
that particular structure. Then after that you can put the data from the
xml files in the right mysql table which belongs to its dtd.
You'd get a column for each xml element. Handling nested xml data would be
a little tougher though.


Thanks for reply Peter,

This is the problem, I've this structure (simplified)

<data1>
<group1>
<field1>
</field1>
<field2>
</field2>
</group1>
<group2>
<field1>
</field1>
</group2>
</data1>

and of course, group number is undefined and field number in each group is
also undefined.
What's the best approach ? for now I use xml_parser_crea te and check
manually everything.

but if I find a better way to handle datas, probably It will be simpler to
parse and save datas in the database,
Bob
Jul 18 '05 #5
Bob Bedford wrote:
Thanks for reply Peter,

This is the problem, I've this structure (simplified)

<data1>
<group1>
<field1>
</field1>
<field2>
</field2>
</group1>
<group2>
<field1>
</field1>
</group2>
</data1>

and of course, group number is undefined and field number in each group
is also undefined.
What's the best approach ? for now I use xml_parser_crea te and check
manually everything.

but if I find a better way to handle datas, probably It will be simpler
to parse and save datas in the database,


Hi Bob,

Well, that's what I meant by nested data. That is a lot trickier.
There are database engines that support native xml data on which you can
use XQuery queries. An example is eXist (http://exist.sourceforge.net/).
But I think you mentioned you want to use MySQL to store the data right?
I did read something about MySQL 5 going to support XPath too, but
that's not 100% sure yet last time I checked.
So for now it's a tough problem to solve with MySQL I'm afraid.

--
http://www.phpforums.nl
Jul 18 '05 #6

"Peter van Schie" <va************ @gmail.com> a écrit dans le message de
news: 42************* **********@news .wanadoo.nl...
Bob Bedford wrote:
Thanks for reply Peter,

This is the problem, I've this structure (simplified)

<data1>
<group1>
<field1>
</field1>
<field2>
</field2>
</group1>
<group2>
<field1>
</field1>
</group2>
</data1>

and of course, group number is undefined and field number in each group
is also undefined.
What's the best approach ? for now I use xml_parser_crea te and check
manually everything.

but if I find a better way to handle datas, probably It will be simpler
to parse and save datas in the database,
Hi Bob,

Well, that's what I meant by nested data. That is a lot trickier.
There are database engines that support native xml data on which you can
use XQuery queries. An example is eXist (http://exist.sourceforge.net/).
But I think you mentioned you want to use MySQL to store the data right?
I did read something about MySQL 5 going to support XPath too, but that's
not 100% sure yet last time I checked.
So for now it's a tough problem to solve with MySQL I'm afraid.

--
http://www.phpforums.nl

Thanks for help Peter,

Probably there is no way to put datas from a XML file directly in a Mysql
database, but does it exist a manner to put datas in an array automatically,
or better in a structure ?

The dream is to have a function that reads a XML file and put it in an array
then use msqlqueries like
insert into mytable
values($struct["group1"]["field1"],$struct["group2"]["field2"]....
does it exists in PHP ?

Jul 21 '05 #7
Check out the various XML code snippets on the Zend site at
http://www.zend.com/codex.php?CID=15. There may be something there that
satisfies your needs.

--
Tony Marston

http://www.tonymarston.net
"Bob Bedford" <be******@notfo rspammershotmai l.com> wrote in message
news:42******** **************@ news.sunrise.ch ...

"Peter van Schie" <va************ @gmail.com> a écrit dans le message de
news: 42************* **********@news .wanadoo.nl...
Bob Bedford wrote:
Thanks for reply Peter,

This is the problem, I've this structure (simplified)

<data1>
<group1>
<field1>
</field1>
<field2>
</field2>
</group1>
<group2>
<field1>
</field1>
</group2>
</data1>

and of course, group number is undefined and field number in each group
is also undefined.
What's the best approach ? for now I use xml_parser_crea te and check
manually everything.

but if I find a better way to handle datas, probably It will be simpler
to parse and save datas in the database,


Hi Bob,

Well, that's what I meant by nested data. That is a lot trickier.
There are database engines that support native xml data on which you can
use XQuery queries. An example is eXist (http://exist.sourceforge.net/).
But I think you mentioned you want to use MySQL to store the data right?
I did read something about MySQL 5 going to support XPath too, but that's
not 100% sure yet last time I checked.
So for now it's a tough problem to solve with MySQL I'm afraid.

--
http://www.phpforums.nl

Thanks for help Peter,

Probably there is no way to put datas from a XML file directly in a Mysql
database, but does it exist a manner to put datas in an array
automatically, or better in a structure ?

The dream is to have a function that reads a XML file and put it in an
array then use msqlqueries like
insert into mytable
values($struct["group1"]["field1"],$struct["group2"]["field2"]....
does it exists in PHP ?


Jul 21 '05 #8
Bob Bedford wrote:
Thanks for help Peter,

Probably there is no way to put datas from a XML file directly in a
Mysql database, but does it exist a manner to put datas in an array
automatically, or better in a structure ?

The dream is to have a function that reads a XML file and put it in an
array then use msqlqueries like
insert into mytable
values($struct["group1"]["field1"],$struct["group2"]["field2"]....
does it exists in PHP ?


Hi Bob,

I see where you want to go, but I don't know of any php library or class
that does just that. Maybe the link Tony posted is helpful. Keep us posted.

--
http://www.phpforums.nl
Jul 21 '05 #9
You can also try searching for XML at http://www.phpclasses.org/

--
Tony Marston

http://www.tonymarston.net
"Peter van Schie" <va************ @gmail.com> wrote in message
news:42******** *************** @news.wanadoo.n l...
Bob Bedford wrote:
Thanks for help Peter,

Probably there is no way to put datas from a XML file directly in a Mysql
database, but does it exist a manner to put datas in an array
automatically, or better in a structure ?

The dream is to have a function that reads a XML file and put it in an
array then use msqlqueries like
insert into mytable
values($struct["group1"]["field1"],$struct["group2"]["field2"]....
does it exists in PHP ?


Hi Bob,

I see where you want to go, but I don't know of any php library or class
that does just that. Maybe the link Tony posted is helpful. Keep us
posted.

--
http://www.phpforums.nl

Jul 21 '05 #10

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

Similar topics

2
1846
by: jcleonard | last post by:
Hi, I'm looking fo a solution to generate automaticaly a PDF file. My aim is to use a template define by a user and to insert dynamicly datas form SQL server in this document. Can you tell me if it exist PDF template like .dot for word ? If such file exist is it possible to generate list of information like aacount report with datas...
0
1783
by: Matthias Blohm | last post by:
Hello, a question about a tool or a possibility how could something work. following situation: we have a database which is full of very sensitive information and needed that db to use our online website. but now we move the website to a server outside our office and needed to replicate only some datas to the online db. with the tool slony i...
1
1218
by: Jamie | last post by:
Hi There, I done a little bit of sql a while back and now I need to start up again. I have got to grip with most of the commands again and managed to create tables etc. One thing I can't remember how to do or find on the web is how to read from a text file.
2
1610
by: DurumDara | last post by:
Hi ! I want to create a database from datas. I want to store my datas in lists/dicts/normal variables. I thinking about that I can use the pickle to serialize/load my datas from the file. But: I remember that in the year of 2004(?) I tried this thing. I store my CD informations in pickled objects (in files).
0
1042
nirmalsingh
by: nirmalsingh | last post by:
hai.. how to split datas in mysql and to access in vb(flexgrid)?
4
2054
by: Amar | last post by:
Hi All, I need to select data from a database table containing huge amount of data. Now I am storing data using one primary key and I am just using simple select statement, and this process gives me the output but it is taking long to execute the query. As much I had heared I want to use some indexing or cluster indexing which might help me...
6
4466
by: vj83 | last post by:
Hi, I have a C#.net application in which i have read the datas from excel sheet and displayed in a datagrid in my Aspx form. The code is here private void Button2_Click(object sender, System.EventArgs e) { try
3
1347
by: wish | last post by:
Dear all, may i like to know how to backup the datas inside the table in linux platform? i use mysql software to create table and store datas. can someone guide me?
2
2025
mageswar005
by: mageswar005 | last post by:
hi, I need one help, How can i Export the Datas from mysql to Excelsheet not csv in php coding.The excelsheet format should be comes under microsoft office excel spreadsheet format.i need all this should be in php.I already tried in google but that code has some problem in excelsheet format. thanks M.Mageswaran
0
7424
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...
0
7365
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7772
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...
1
7376
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...
0
7709
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3415
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...
0
3409
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1841
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
1
988
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.