Jump to content

XML content into MySQL......


unplugged_web

Recommended Posts

This is what I've got so far but all I get is errors. This is the code I'm using to get the xml file into the database:

<?php$xml = simplexml_load_file('feed.xml');foreach($xml->children() as $product) { mysql_query("INSERT INTO data (name,desc,tracking,brand)   VALUES ('$product->text->name','$product->text->desc','$product->uri->Track','$product->brand->brandName')");} ?>

and this is the XML file:

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE cafProductFeed SYSTEM "http://www.window.com/DTD/affiliate/datafeed.1.4.dtd"><cafProductFeed><datafeed id="36" merchantId="36" merchantName="Company"><prod id="12345678">    <brand>        <brandName>Universal Pictures</brandName>    </brand>    <cat>        <CatId>550</CatId>        <Cat>Blu-Ray</Cat>        <mCat>Blu-ray</mCat>    </cat>    <price curr="USD">        <buynow>44.99</buynow>        <delivery>1.99</delivery>        <store>0.00</store>    </price>    <text>        <name>Product</name>        <desc>description text</desc>    </text>    <uri>        <Track>http://www.tracking.com</Track>        <Image>http://images.domain.com/</Image>        <mImage>http://www.images.domain.com</mImage>        <mLink>http://www.domain.com/blu-ray/bourne-identity/the-bourne-supremacy/the-bourne-ultimatum/</mLink>    </uri>    <vertical/>    <pId>1234567</pId>    <largeImage>http://large.image.com</largeImage>    <ean>1234567</ean></prod><prod id="12345678">    <brand>        <brandName>Universal Pictures</brandName>    </brand>    <cat>        <CatId>550</CatId>        <Cat>Blu-Ray</Cat>        <mCat>Blu-ray</mCat>    </cat>    <price curr="USD">        <buynow>44.99</buynow>        <delivery>1.99</delivery>        <store>0.00</store>    </price>    <text>        <name>Product</name>        <desc>description text</desc>    </text>    <uri>        <Track>http://www.tracking.com</Track>        <Image>http://images.domain.com/</Image>        <mImage>http://www.images.domain.com</mImage>        <mLink>http://www.domain.com/blu-ray/bourne-identity/the-bourne-supremacy/the-bourne-ultimatum/</mLink>    </uri>    <vertical/>    <pId>1234567</pId>    <largeImage>http://large.image.com</largeImage>    <ean>1234567</ean></prod></datafeed></cafProductFeed>

but all I get is errors:

Warning: simplexml_load_file(): http://www.domains.co.uk/feed.xml:1: parser error : Space required after the Public Identifier in /home/domain/parse.php on line 2

Warning: simplexml_load_file(): <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> in /home/domain/parse.php on line 2

Warning: simplexml_load_file(): ^ in /home/domain/parse.php on line 2

Warning: simplexml_load_file(): http://www.domains.co.uk/feed.xml:1: parser error : SystemLiteral " or ' expected in /home/domain/parse.php on line 2

Warning: simplexml_load_file(): <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> in /home/domain/parse.php on line 2

Warning: simplexml_load_file(): ^ in /home/domain/parse.php on line 2

Warning: simplexml_load_file(): http://www.domains.co.uk/feed.xml:1: parser error : SYSTEM or PUBLIC, the URI is missing in /home/domain/parse.php on line 2

Warning: simplexml_load_file(): <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> in /home/domain/parse.php on line 2

Warning: simplexml_load_file(): ^ in /home/domain/parse.php on line 2

Fatal error: Call to a member function children() on a non-object in /home/domain/parse.php on line 3

 

I've never done anything like this before and would be so grateful for some help please

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...