Muppy wrote:[color=blue]
>with phpmyadmin i export a table of a mysql db in xml file. Now i want
>import a xml file in a mysql db.
>How can i do??
>Thanks
>Andrea[/color]
I don't know phpmyadmin, but if it has a export to xml, does it not
have a import from xml to go along?
If it doesn't make your own :)
I don't know what your xml data looks like, but it's very
easy to transform
insert into table (name, eyecolor) values ('Pedro', 'brown');
insert into table (name, eyecolor) values ('Muppy', 'blue');
and then mysql_query every one of the insert statments.
Happy Coding :-)
--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.
> I don't know phpmyadmin, but if it has a export to xml, does it not[color=blue]
> have a import from xml to go along?[/color]
no, it doesn't have.
[color=blue]
> If it doesn't make your own :)
>
>
> I don't know what your xml data looks like, but it's very
> easy to transform[/color]
It's not esay for me ;)
Any help will be appreciated
Thanks
Andrea
then, for each record, get the respective values, and insert into sql
I am treating all values as strings (quoting them with ')
you might want to test the column names and do it differently
<?php
foreach ($records[1] as $record) {
preg_match_all( '#<(.*)>(.*)</\1>#Us', $record, $values);
// $values[1] has the column names
// $values[2] has the values to insert
$sql = "insert into table ("
. implode(', ', $values[1])
. ") values ('"
. implode("', '", $values[2])
. "')";
echo $sql, '<br />'; ### or mysql_query($sq l)
}
?>
--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.
On 4 Oct 2003 18:10:28 GMT, Pedro <hexkid@hotpop. com> wrote:
[color=blue]
>Muppy wrote:[color=green]
>> It's not esay for me ;)
>> Any help will be appreciated[/color]
>
>Ever tried regexps?[/color]
You can't parse XML fully with just regexps. Use an XML parser:
Muppy wrote on Saturday 04 October 2003 12:24:
[color=blue][color=green]
>> Ever tried regexps?[/color]
>
> no ;(
> Many thanks for the help!
> Andrea[/color]
Either use XML parser in PHP per Andy's suggestion or use ActiveLink PHP XML
Package to manipulate XML (no PHP XML libs required):
Download ActiveLink PHP XML Package for free. ActiveLink PHP XML Package provides means to parse, read, modify and output XML and XML documents without using any PHP XML libraries. Included classes are: XML, XMLDocument, XMLBranch, XMLLeaf, RSS, Tag, Tree, Branch, Leaf, File, Socket, HTTPClient.
Comment