+ Reply to Thread
Results 1 to 5 of 5

 

Thread: xml > csv into mysql with a sprinkle of php

  1. #1
    Super Member

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Costa Del Sheffield
    Posts
    2,838
    Thanks
    5
    Thanked 18 Times in 14 Posts


    nice descriptive subject there

    okay, I am now fine with putting CSV data into mysql database and doing stuff with it from there. easy.

    but then I come across crazy merchants with xml feeds! really what are they playing at, anyway its just your normal xml like:

    <?xml version="1.0"?>
    <Products>
    blah blah
    </Products>

    with lots of stuff in the middle that I want.

    I was hoping excel would open it up how I wanted, but it hasn't so im a bit stumped as to where to go next.

    Idealy Id like some script to parse that into proper CSV then I could run thatthrouhg the other script wich puts it into database. But if thats going to be a bit tricky just something that could get it as CSV on my computer and id upload from there.

    Just looking for pointers really, what should I be searching for?

    as always, help much appreciated
    Dan Morley
    alpharooms.com
    daniel at alpharooms dot com - Hotels, Flights, Airport Transfers, Care Hire + More! sign up
    My Blog | Cheap Holidays

  2. #2
    Registered User

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Worthing
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Dan,

    The latest version of Excel (not sure if its XP or 2003) loads them fine.

    Im using 2002 at the mo (must have loaded an old version when I last rebuilt) but that works with some using the "Data - Import External Data - Import Data" feature

    Cheers
    Jez

  3. #3
    Super Member

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Costa Del Sheffield
    Posts
    2,838
    Thanks
    5
    Thanked 18 Times in 14 Posts
    damn, im stuck with 2000

    will go see what I can find, any other ideas welcome though
    Dan Morley
    alpharooms.com
    daniel at alpharooms dot com - Hotels, Flights, Airport Transfers, Care Hire + More! sign up
    My Blog | Cheap Holidays

  4. #4
    Registered User

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Cornwall
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Found this xml converter if it's any use to you, priced at about £22.

    http://www.rustemsoft.com/home.htm#

  5. #5
    Registered User

    Status
    Offline
    Join Date
    Dec 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    http://www.hansanderson.com/php/xml
    a free php class to parse xml into arrays

    PHP Code:
    include 'xmlize.inc';
    //grab xml file into a string and parse it with the array
    $file file('xml_file.xml');
    $xml_in_array_format xmlize(implode(''$file));
    //traverse it's nasty naming format and grab the item you want into a readable variable
    $something $xml_in_array_format['something'][0]['#'];
    //do some random sql query with our spanky new xml data in a variable
    $result mysql_query("INSERT INTO table(field) VALUES '{$something}'"); 
    the naming format it uses to fit everything into an array is a bit grim, but our friend here is print_r():
    PHP Code:
    echo '<pre>'print_r($xml_array), '</pre>'
    i just made up the code abovce, but it should all check out ok in use.

    good luck

+ Reply to Thread


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2