Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Updating MySQL Using XML?
Old 02-28-2011, 06:54 PM Updating MySQL Using XML?
Skilled Talker

Posts: 83
Trades: 0
Hi,

Apologies to keep going on about this but I have hit a brick wall over updating my database with XML. I have spent around 100 hours on this and so far I can only copy the file, I am unable so far to update my database with the information from the XML file. I would be very grateful for any help you can offer to fix this.

Code:
----Code so far---->

$xmlReader = new XMLReader();

$filename = "datafeed_98057.xml";
$url = "http://www.domain.co.uk/datafeed.xml";

file_put_contents($filename, file_get_contents($url));

$xmlReader->open($filename);

while ($xmlReader->read())

{

switch ($xmlReader->name)

{

case'prod':

$dom = new DOMDocument();
$domNode = $xmlReader->expand();
$element = $dom->appendChild($domNode);
$domString = utf8_encode($dom->saveXML($element));
$prod = new SimpleXMLElement($domString);

$id = $prod->prod['id'];
$description = $prod->name;
$image = $prod->awImage;
$fulldescription = $prod->desc;

//insert query
if(strlen($prod) > 0)

{
$query = mysql_query("REPLACE INTO productfeed
(id, description, fulldescription, image)
VALUES ('$id','$description','$image','$fulldescription') ");
echo $id . "has been inserted </br>";
}
else{echo ("This does not work </br>");}
}
This is an outline of the XML feed I am using, it only includes one item which I am using as a test:

Code:
- <merchant id="1829" name="Pinesolutions.co.uk">
- <prod id="39920873" pre_order="no" web_offer="no" in_stock="yes" hotPick="no" adult="no">
- <text lang="EN">
  <name>Oakleigh Wall Mirror 60x90</name> 
  <desc>Mirrors are useful anywhere in the house. Not only are they functional allowing you to see your reflection in order to look your best, they also add elegance to any room theyre placed in. We offer a variety of mirrors to fit your decorating tastes as well as wall space. The Oakleigh Wall Mirror radiates an elegant simplistic style, while offering a generous size glass. The Oakleigh Wall Mirror s frame is crafted from solid hardwood and is lacquered with a protective finish to guard against dust and unexpected stains. The Oakleigh Wall Mirror is versatile and can be hung portrait style at the top of a staircase or landscape. The Oakleigh Wall Mirrors light colour means it also complements all of the furniture in our Camden Painted Range because the range has ash tops. The Oakleigh Wall Mirror has fewer knots than traditional oak wood, but is built just as sturdy so you can be certain it will last you through the generations to come.</desc> 
  </text>
- <uri lang="EN">
  <awTrack>http://www.awin1.com/pclick.php?p=39920873&a=98057&m=1829</awTrack> 
  <awImage>http://images.productserve.com/preview/1829/39920873.jpg</awImage> 
  <mLink>http://www.pinesolutions.co.uk/bedroom-furniture/mirrors/wall-mirrors/oakleigh-wall-mirror-60x90/</mLink> 
  <mImage>http://media.pinesolutions.co.uk/images/products/903.333.3.4.jpg</mImage> 
  </uri>
- <price curr="GBP">
  <buynow>40.00</buynow> 
  </price>
- <cat>
  <awCatId>424</awCatId> 
  </cat>
  <brand /> 
  </prod>
  </merchant>
__________________
»
Please login or register to view this content. Registration is FREE
- Interactive maps for websites
»
Please login or register to view this content. Registration is FREE
for web developers
DmitryS is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-01-2011, 12:02 AM Re: Updating MySQL Using XML?
shivaji's Avatar
Ultra Talker

Posts: 321
Trades: 0
Did you get any error?
__________________

Please login or register to view this content. Registration is FREE
- uncommon free scripts

Please login or register to view this content. Registration is FREE
- Städte, Sport, Party, Gourment, Apartments, Hotels
shivaji is offline
Reply With Quote
View Public Profile Visit shivaji's homepage!
 
Reply     « Reply to Updating MySQL Using XML?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09792 seconds with 12 queries