how to save .xml data to mysql?

Discussion in 'PHP' started by s.jns, Oct 23, 2010.

  1. #1
    Hi,

    May one of you could help me, please...
    i appreciated for every suggestions here...

    if i have .xml data update daily and that inside as:

    <gesmes:Envelope>
    <gesmes:subject>Reference Scores</gesmes:subject>
    -
    <gesmes:Sender>
    <gesmes:name>Game Information Scores</gesmes:name>
    </gesmes:Sender>
    -
    <Cube>
    -
    <Cube time="2010-10-13">
    <Cube scores="GameA1" value="1.5803"/>
    <Cube scores="GameA2" value="21.35"/>
    ............etc
    <Cube scores="GameA15" value="135"/>
    </Cube>
    </Cube>
    </gesmes:Envelope> 
    PHP:
    then i must store it to mysql also daily, would be look like:
    CREATE TABLE IF NOT EXISTS `scrore_table` (
      `scrore_id` int(11) NOT NULL auto_increment,
      `scrore_title` varchar(32) collate utf8_bin NOT NULL default '',
      `scores` varchar(15) collate utf8_bin NOT NULL default '',
      `decimal_place` char(1) collate utf8_bin NOT NULL,
      `value` float(15,8) NOT NULL,
      `date_updated` datetime NOT NULL default '0000-00-00 00:00:00',
      PRIMARY KEY  (`currency_id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1; ;
    
    INSERT INTO `scrore_table` (`scrore_id`, `scrore_title`, `scores`, `decimal_place`, `value`, `date_updated`) VALUES
    (1, 'Game Class A0', 'GameA0', '2', 1.00000000, '2010-04-06 22:00:54'),
    (2, 'Game Class A1', 'GameA1', '2', 1.58030000,  '2010-04-06 22:00:54'),
    (3, 'Game Class A2', 'GameA2', '2', 21.3503000,  '2010-04-06 22:00:54'),
    ..............................etc
    (15, 'Game Class A15', 'GameA15', '2', 135,  '2010-04-06 22:00:54');  
    PHP:
    what should i do to create it? any assists are welcome and many thanks
     
    Last edited: Oct 23, 2010
    s.jns, Oct 23, 2010 IP
  2. AnoxiA

    AnoxiA Peon

    Messages:
    27
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    setup a cronjob for a php script which fetch's the XML page and then parse the XML with either XML Parser OR SimpleXML. then just store it in your database
     
    AnoxiA, Oct 23, 2010 IP
  3. s.jns

    s.jns Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    Hi AnoxiA,

    could you please to let me see the samples php code of XML Parser OR SimpleXM? that suitable with my case. any another else?
    Thank You.
     
    s.jns, Oct 24, 2010 IP
  4. flight05

    flight05 Active Member

    Messages:
    122
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    61
    #4
    Convert it to css and then to mysql
     
    flight05, Oct 24, 2010 IP