2012-02-04 2 views
1

Plex Media Server 골짜기 foreach에서 정보를 얻고 싶습니다. URL에서 콘텐츠를 가져 오는 데 성공했지만 페이지에 인쇄하려는 정보를 가져올 수 없습니다. 이 URL에서 print_r의 데이터입니다Plex Media Server에서 XML 데이터 가져 오기

object(SimpleXMLElement)[1] 
    public '@attributes' => 
    array 
     'size' => string '349' (length=3) 
     'mediaTagPrefix' => string '/system/bundle/media/flags/' (length=27) 
     'mediaTagVersion' => string '1322272914' (length=10) 
     'sortAsc' => string '1' (length=1) 
     'viewGroup' => string 'movie' (length=5) 
     'viewMode' => string '458803' (length=6) 
     'art' => string '/:/resources/movie-fanart.jpg' (length=29) 
     'title1' => string 'Filmer' (length=6) 
     'identifier' => string 'com.plexapp.plugins.library' (length=27) 
    public 'Video' => 
    array 
     0 => 
     object(SimpleXMLElement)[2] 
      public '@attributes' => 
      array 
       ... 
      public 'Media' => 
      object(SimpleXMLElement)[351] 
       ... 
      public 'Genre' => 
      array 
       ... 
      public 'Writer' => 
      array 
       ... 
      public 'Director' => 
      object(SimpleXMLElement)[356] 
       ... 
      public 'Country' => 
      object(SimpleXMLElement)[357] 
       ... 
      public 'Role' => 
      array 
       ... 
    1 => 
    object(SimpleXMLElement)[3] 
     public '@attributes' => 
     array 
      ... 
     public 'Media' => 

And so on... 

:

SimpleXMLElement Object ([@attributes] => Array ([size] => 349 [mediaTagPrefix] => /system/bundle/media/flags/ [mediaTagVersion] => 1322272914 [sortAsc] => 1 [viewGroup] => movie [viewMode] => 458803 [art] => /:/resources/movie-fanart.jpg [title1] => Filmer [identifier] => com.plexapp.plugins.library) [Video] => Array ([0] => SimpleXMLElement Object ([@attributes] => Array ([ratingKey] => 2663 [key] => /library/metadata/2663 [studio] => Touchstone Pictures [type] => movie [title] => 10 Things I Hate About You [contentRating] => PG-13 [summary] => "10 Things I Hate About You" är en amerikansk långfilm från 1999 i regi av Gil Junger. När Cameron börjar high school förälskar han sig snabbt i den söta Bianca. Han hjälper henne med hemläxorna i franska för att få henne att bli intresserad av honom. När han ber att få gå på skolbalen med henne får han dock veta att hennes pappa har bestämt att hon inte får gå på dejt så länge Biancas syster Kat är singel. Kat är ständigt på dåligt humör och ovänlig och definitivt inte någon man vill gå på dejt med. Cameron måste också konkurrera om Biancas gunst med snyggingen Joey. Cameron kommer då på en plan: att be Pat, som enligt ryktet har sålt sin lever för att köpa högtalare, att gå med Kat på skolbalen mot betalning. [rating] => 7 [year] => 1999 [thumb] => /library/metadata/2663/thumb?t=1328119876 [art] => /library/metadata/2663/art?t=1328119876 [duration] => 5940000 [originallyAvailableAt] => 1999-03-31 [addedAt] => 1328119758 [updatedAt] => 1328119876) [Media] => SimpleXMLElement Object ([@attributes] => Array ([id] => 2614 [duration] => 5611000 [bitrate] => 1021 [width] => 544 [height] => 304 [aspectRatio] => 1.78 [audioChannels] => 2 [audioCodec] => mp3 [videoCodec] => mpeg4 [videoResolution] => sd [container] => avi [videoFrameRate] => PAL [optimizedForStreaming] => 0) [Part] => SimpleXMLElement Object ([@attributes] => Array ([key] => /library/parts/2628/file.avi [duration] => 5611000 [file] => G:\Movies\10 things that I hate about you (1999)\10 things that I hate about you (1999).avi [size] => 733679616))) [Genre] => Array ([0] => SimpleXMLElement Object ([@attributes] => Array ([tag] => Coming of age)) [1] => SimpleXMLElement Object ([@attributes] => Array ([tag] => Komedi))) [Writer] => Array ([0] => SimpleXMLElement Object ([@attributes] => Array ([tag] => Karen McCullah Lutz)) [1] => SimpleXMLElement Object ([@attributes] => Array ([tag] => Kirsten Smith))) [Director] => SimpleXMLElement Object ([@attributes] => Array ([tag] => Gil Junger)) [Country] => SimpleXMLElement Object ([@attributes] => Array ([tag] => USA)) [Role] => Array ([0] => SimpleXMLElement Object ([@attributes] => Array ([tag] => Allison Janney)) [1] => SimpleXMLElement Object ([@attributes] => Array ([tag] => Larry Miller)) [2] => SimpleXMLElement Object ([@attributes] => 

이 코드는 내가 지금 가지고 :

은 URL로부터 위해서 var_dump입니다

$url = 'http://localhost:32400/library/sections/12/all'; 
$achxml = simplexml_load_file($url); 
foreach($achxml->attributes AS $ach) { 
    echo $ach->Video['title'].'<br>'; 
} 

내가 빠져 나가는 유일한 방법은 ... 음 - 아무것도! 전혀 인쇄하지 않습니다. 그래서 지금 내게 묻습니다. foreach의 무엇이 잘못 되었습니까? PlexNine에 대해 자세히 알아 보거나 여기에서 무엇을 부르는지 여기에서 확인할 수 있습니다. http://wiki.plexapp.com/index.php/PlexNine_AdvancedInfo

감사합니다.

답변

1

지금이 작업이 있습니다. 해결책은 다음과 같습니다.

foreach($achxml->Video AS $child) { 
    echo $child['title']; 
} 
관련 문제