473,626 Members | 3,439 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 2221
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
1850
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 coming for Database like Sql server.
0
1788
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 found out , that some tables could be replicated, but in some tables are some information, which we...
1
1220
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
1614
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
1046
nirmalsingh
by: nirmalsingh | last post by:
hai.. how to split datas in mysql and to access in vb(flexgrid)?
4
2057
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 but I am not so familiar with these things. So if any one having some solutions to execute the...
6
4474
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
1349
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
2032
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
8268
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
8707
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8510
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7199
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
6125
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
5575
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
4093
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...
1
2628
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
2
1512
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.