php xml işleme en iyi yolu

2 Cevap php

i veri ayıklamak ve eklemek istediğiniz xml belgelerin bir listesi var benim veritabanı yönlü php iyi?

örnek belgeler

http://xml.gamebookers.com/sports/football.xml http://www.bet-at-home.com/oddxml.aspx?lang=en

Bunu yapmak için en iyi yolu / fonksiyonu olacaktır, bir futbol takımlarından oran ayıklamak bunların oran kazanan ve benim veritabanı hangi yolu var armatürleri ile maç istiyorum?

2 Cevap

SimpleXML için git (http://php.net/simplexml).

Çok kolayca dosyalar arasında gezinmek ve hatta daha sezgisel XML gezinme için XPath'i destekler.

Küçük bir örnek:

<?php
$xml = simplexml_load_file('http://xml.gamebookers.com/sports/football.xml');
foreach ($xml->partybets->event as $event)
{
  echo "<h3>", $event->eventName, "</h3>";
  echo "<p><strong>Odd</strong>: ", $event->odd1, "</p>";
}
?>

Sen bulabilirsiniz

SimpleXml

veya

phpDom

interessting. Simple XML is, as the name implies, pretty simple. But as as longs as you just want to iterate through a structure of data it's the right thing fveya the job... dom is the choice of you need to write xml too.