Jump to content

XML content into MySQL......


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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...