5 Replies - 1340 Views - Last Post: 04 March 2011 - 08:58 AM Rate Topic: -----

#1 bukatin  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 28
  • Joined: 19-January 11

Insert XML data to SQL table

Posted 03 March 2011 - 02:06 AM

Hi,

I bet you guys can help me on this. I don't know how to handle xml files. Here's the scenario, I have XML file, i want that each data from my xml file will be inserted into my database. How can I do that?
Is This A Good Question/Topic? 0
  • +

Replies To: Insert XML data to SQL table

#2 marinus  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 135
  • View blog
  • Posts: 575
  • Joined: 14-April 10

Re: Insert XML data to SQL table

Posted 03 March 2011 - 02:29 AM

Solution.

When you get the data that you want in XML send it to SQL Server

VIA your requirement , i would put an insertcommand in a loop .

With each iteration through the XML File I would send it to specific field

in the database

Not so hard is it. ;)

This post has been edited by marinus: 03 March 2011 - 02:34 AM

Was This Post Helpful? 0
  • +
  • -

#3 keakTheGEEK  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 107
  • View blog
  • Posts: 344
  • Joined: 23-February 10

Re: Insert XML data to SQL table

Posted 04 March 2011 - 12:25 AM

Most modern DBMSs have built in features to handle xml data. Depending on what database you are using, you should look into that. I know MS Sql Server 2005 and up has an xml data type. You could pass the contents of the xml file to a stored procedure and insert the data that way...
Was This Post Helpful? 0
  • +
  • -

#4 bukatin  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 28
  • Joined: 19-January 11

Re: Insert XML data to SQL table

Posted 04 March 2011 - 02:49 AM

thanks... I'm using PHP and My Sql. Anyone can give me sample functions or class on this?
Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5672
  • View blog
  • Posts: 22,524
  • Joined: 23-August 08

Re: Insert XML data to SQL table

Posted 04 March 2011 - 05:40 AM

I'm going to move this to PHP, because that's probably the best place for it.

Have you mapped your XML schema to a database table? If you provide some example data and code, we can help.
Was This Post Helpful? 0
  • +
  • -

#6 VolcomMky  Icon User is offline

  • D.I.C Regular

Reputation: 72
  • View blog
  • Posts: 291
  • Joined: 13-May 09

Re: Insert XML data to SQL table

Posted 04 March 2011 - 08:58 AM

I would suggest using
htmlentities($xmlData,ENT_QUOTES)


And then html_entity_decode when you retrieve it from the database.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1