dziś 1sze starcie z XMLem. Chciałbym odczytać takie cudo:
<?php $xmlstr = <<<XML <Group title="50's, 60's, 70's and 80's" comment=""> <Station title=".977 The 80's Channel" url="http://www.977music.com/"> <Source>http://www.977music.com/tunein/web/80s.asx</Source> </Station> <Station title=".977 The Oldies Channel" url="http://www.977music.com/"> <Source>http://www.977music.com/tunein/web/oldies128.asx</Source> </Station> <Station title="1.FM - 50s and 60s" url="http://1.fm/Stations/60s_70s/TuneIn.aspx"> <Source>http://60s.1.fm/60s_70s128k</Source> <Source>http://1.fm/TuneIn/WM/energy60s_70s32k/Listen.aspx</Source> </Station> </Group> <Group title="rock stations" comment=""> <Station title="1.FM - 80s" url="http://1.fm/Stations/80s_90s/TuneIn.aspx"> <Source>http://80s.1.fm/energy80s128k</Source> <Source>http://1.fm/TuneIn/WM/energy80s32k/Listen.aspx</Source> </Station> <Station title="A Flock of Eighties" url="http://www.accuradio.com/mobile"> <Source>http://shoutcast.accuradio.com:8056</Source> <Source>http://dupa</Source> </Station> <Station title="A Flock of Eighties" url="http://www.accuradio.com/mobile"> <Source>http://dupa</Source> <Source>http://shoutcast.accuradio.com:8056</Source> </Station> </Group> XML; ?>
udaje mi się odczytać ALE no właśnie gdy nie ma tego Drugiego <Group> ( docelowo tych sekcji jest duzo wiecej ) i omija mi np drugie <source> czyli gdy mam dwa tagi <source> w jednym <station>.
Odczytuje to jak znalazlem w manualu
<?php include 'fileXml.php'; $xml = new SimpleXMLElement($xmlstr); foreach ( $xml->xpath('//Station') as $Station ) { } ?>
i mam z tym klopot.
pozdrawiam