Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert XML Data into MySQL table

Status
Not open for further replies.

NewTerminator

Programmer
Apr 28, 2003
22
IN
Is there any way i can insert data from an XML file directly to a MySQL table (something similar to SQLXML does for SQL Server 2000)?

Any help would be appreciated!

thanks


san
 
do u wnat to insert the file or just the contents?

Known is handfull, Unknown is worldfull
 
Thanks for your reply.

I would like to insert the contents of the XML file to the DB. The XML file can range anywhere from 900 lines to 9000 lines. Hope this helps you answer my query!

Thanks

San
 
yes u can insert it using BLOB field (text field).

read the file using fopen and store the contents in a string.

$strng=addslashes($strng);
$sql="insert into table values('$strng')";
mysql_query($sql);

Known is handfull, Unknown is worldfull
 
thanks for the reply? can this be taken care in ASP?.

BTW is it possible to create the table dynamically?
 
yes this can also be done in ASP using file scripting object. and yes tables can be created dynamically...

Known is handfull, Unknown is worldfull
 
Ur answer is a good news to me ! Thanks for it. Do u know any web sites where i can get examples for the above?
 
tek-tips will do. go to the ASP forum and do a search for file scripting object. :)

Known is handfull, Unknown is worldfull
 
Not found much info on the problem that i had. Do u have any other place where i can i get it?
 
str=""
Set fso=Server.CreateObject("System.FileScriptingObject")
set txt=fso.opentextfile(PATH_OF_XML_FILE)
while not txt.atEndOfStream
str=str+(txt.ReadLine)
wend
txt.Close
response.write str

Known is handfull, Unknown is worldfull
 
Is that FileScriptingObject or FileSystemObject ?? FileScriptingObject does not seem to work. Anyway, how do i create a table based on the XML feed and dump the values into it ? Thanks
 
oops made a mistake:
Set fso=Server.CreateObject("Scripting.FileSystemObject")


about ur second question: i knwo nothing bout XML. all i know is that u can read and write to files...

:(

Known is handfull, Unknown is worldfull
 
Thanks for ur help! My major concern was abt the XML part :). Its ok, I will try to figure it out. Meanwhile if someone gets it here, plz help me :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top