Basically, I have a fairly large XML feed that I am trying to read and I need to select only the nodes that have a specific child.
Here is an excerpt of the XML file with multiple nodes:
<event> <event_datetimeGMT>2011-05-07 00:05</event_datetimeGMT> <gamenumber>182331575</gamenumber> <sporttype>Basketball</sporttype> <league>NBA</league> <IsLive>No</IsLive> <participants> <participant> <participant_name>Check The Live NBA Folder</participant_name> <contestantnum>1001</contestantnum> <rotnum>1001</rotnum> <visiting_home_draw>Visiting</visiting_home_draw> </participant> <participant> <participant_name>For Our Live Offerings</participant_name> <contestantnum>1002</contestantnum> <rotnum>1002</rotnum> <visiting_home_draw>Home</visiting_home_draw> </participant> </participants> <periods> <period> <period_number>0</period_number> <period_description>Game</period_description> <periodcutoff_datetimeGMT>2011-05-07 00:05</periodcutoff_datetimeGMT> <period_status>H</period_status> <period_update>offline</period_update> <spread_maximum>20000</spread_maximum> <moneyline_maximum>10000</moneyline_maximum> <total_maximum>10000</total_maximum> <spread> <spread_visiting>0</spread_visiting> <spread_adjust_visiting>-105</spread_adjust_visiting> <spread_home>0</spread_home> <spread_adjust_home>-105</spread_adjust_home> </spread> </period> </periods> </event> <event> <event_datetimeGMT>2011-01-22 16:00</event_datetimeGMT> <gamenumber>191794779</gamenumber> <sporttype>Basketball</sporttype> <league>NCAA</league> <IsLive>No</IsLive> <participants> <participant> <participant_name>George Mason</participant_name> <contestantnum>527</contestantnum> <rotnum>527</rotnum> <visiting_home_draw>Visiting</visiting_home_draw> </participant> <participant> <participant_name>James Madison</participant_name> <contestantnum>528</contestantnum> <rotnum>528</rotnum> <visiting_home_draw>Home</visiting_home_draw> </participant> </participants> <periods> </periods> </event> <event> <event_datetimeGMT>2011-01-22 17:00</event_datetimeGMT> <gamenumber>191794780</gamenumber> <sporttype>Basketball</sporttype> <league>NCAA</league> <IsLive>No</IsLive> <participants> <participant> <participant_name>Ohio State</participant_name> <contestantnum>529</contestantnum> <rotnum>529</rotnum> <visiting_home_draw>Visiting</visiting_home_draw> </participant> <participant> <participant_name>Illinois</participant_name> <contestantnum>530</contestantnum> <rotnum>530</rotnum> <visiting_home_draw>Home</visiting_home_draw> </participant> </participants> <periods> </periods> </event>
This is the PHP code minus the query that I need to create:
$source = 'http://xml.pinnaclesports.com/pinnacleFeed.aspx?';
$sitemap = simplexml_load_file($source);
$xpath_results = $sitemap->xpath('[b]<QUERY GOES HERE OBV>[b]');
I am basically just lost on how to get this query to return the COMPLETE <event> node if it has a child node that has the <league> AND <sporttype> attributes equal to specific values. For example sake, lets make the <league> value we are looking for "NBA" and the <sporttype> value "Basketball".
If there are easier ways that do not incorporate XPath I am fine with using that. The way I return these nodes is irrelevant, I just need the nodes.
This post has been edited by glandrum101: 21 January 2011 - 10:51 AM

New Topic/Question
Reply




MultiQuote




|