Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> odczyt informacji z XML - problem
john_doe
post
Post #1





Grupa: Zarejestrowani
Postów: 873
Pomógł: 25
Dołączył: 24.07.2005

Ostrzeżenie: (0%)
-----


Witajcie,
dziś 1sze starcie z XMLem. Chciałbym odczytać takie cudo:

  1. <?php
  2. $xmlstr = <<<XML
  3. <Group title="50's, 60's, 70's and 80's" comment="">
  4.             <Station title=".977 The 80's Channel" url="http://www.977music.com/">
  5.                 <Source>http://www.977music.com/tunein/web/80s.asx</Source>
  6.             </Station>
  7.             <Station title=".977 The Oldies Channel" url="http://www.977music.com/">
  8.                 <Source>http://www.977music.com/tunein/web/oldies128.asx</Source>
  9.             </Station>
  10.             <Station title="1.FM - 50s and 60s" url="http://1.fm/Stations/60s_70s/TuneIn.aspx">
  11.                 <Source>http://60s.1.fm/60s_70s128k</Source>
  12.                 <Source>http://1.fm/TuneIn/WM/energy60s_70s32k/Listen.aspx</Source>
  13.             </Station>
  14. </Group>
  15. <Group title="rock stations" comment="">
  16.             <Station title="1.FM - 80s" url="http://1.fm/Stations/80s_90s/TuneIn.aspx">
  17.                 <Source>http://80s.1.fm/energy80s128k</Source>
  18.                 <Source>http://1.fm/TuneIn/WM/energy80s32k/Listen.aspx</Source>
  19.             </Station>
  20.             <Station title="A Flock of Eighties" url="http://www.accuradio.com/mobile">
  21.                 <Source>http://shoutcast.accuradio.com:8056</Source>
  22.                 <Source>http://dupa</Source>
  23.             </Station>
  24.             <Station title="A Flock of Eighties" url="http://www.accuradio.com/mobile">
  25.                 <Source>http://dupa</Source>
  26.                 <Source>http://shoutcast.accuradio.com:8056</Source>                
  27.             </Station>            
  28. </Group>
  29.  
  30. XML;
  31. ?>


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

  1. <?php
  2.  
  3.    include 'fileXml.php';
  4.  
  5.    $xml = new SimpleXMLElement($xmlstr);
  6.  
  7.    foreach ( $xml->xpath('//Station') as $Station )  
  8.    {
  9.        echo $Station->Source,  '<br />';
  10.    }
  11.  
  12. ?>


i mam z tym klopot.
pozdrawiam

Ten post edytował john_doe 11.12.2008, 12:49:54
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.09.2025 - 11:44