Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [XML][PHP] Jak wyświetlić zmienną pobraną z XML
lekosm2
post
Post #1





Grupa: Zarejestrowani
Postów: 141
Pomógł: 0
Dołączył: 9.10.2015

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


Witam, pobieram ze strony dane za pomocą funkcji simplexml_load_file chciałbym jednak z pośród wsystkich naych wyciągnąć dla przykładu jedną zmienną z nickiem.
Poniżej przedstawiam dane pliku xml po wykonaniu funkcji print_r
  1. SimpleXMLElement Object
  2. (
  3. [@attributes] => Array
  4. (
  5. [globalSearch] => 1
  6. [lang] => en_gb
  7. [requestUrl] => character-sheet.xml
  8. )
  9.  
  10. [tabInfo] => SimpleXMLElement Object
  11. (
  12. [@attributes] => Array
  13. (
  14. [subTab] => profile
  15. [tab] => character
  16. [tabGroup] => character
  17. [tabUrl] => r=Serwerej&cn=Nick&gn=Heroes
  18. )
  19.  
  20. )
  21.  
  22. [characterInfo] => SimpleXMLElement Object
  23. (
  24. [character] => SimpleXMLElement Object
  25. (
  26. [@attributes] => Array
  27. (
  28. [battleGroup] => Theatre of Dreams
  29. [charUrl] => r=Serwerej&cn=Nick&gn=Heroes
  30. [class] => Druid
  31. [classId] => 11
  32. [classUrl] => c=Druid
  33. [faction] =>
  34. [factionId] => 1
  35. [gender] =>
  36. [genderId] => 0
  37. [guildName] => Heroes
  38. [guildUrl] => r=Serwerej&gn=Heroes
  39. [lastModified] =>
  40. [level] => 80
  41. [name] => Nick
  42. [points] => 355
  43. [prefix] =>
  44. [race] => Tauren
  45. [raceId] => 6
  46. [realm] => Serwerej
  47. [suffix] =>
  48. [titleId] =>
  49. )
  50.  
  51. [modelBasePath] => SimpleXMLElement Object
  52. (
  53. [@attributes] => Array
  54. (
  55. )
  56.  
  57. )
  58.  
  59. )
  60.  
  61.  
  62. )
  63. )


W jaki sposób mam wyświetlić nick, bo próbowałem tak tj. echo $xml->characterInfo->character->@attributes->name;
Lecz to na pewno było źle.. Pomoże ktoś? Z góry dziękuję!

Ten post edytował lekosm2 8.07.2016, 21:26:07
Go to the top of the page
+Quote Post
markuz
post
Post #2





Grupa: Zarejestrowani
Postów: 1 240
Pomógł: 278
Dołączył: 11.03.2008

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


  1. echo $xml->characterInfo->character->name;


--------------------
Go to the top of the page
+Quote Post
lekosm2
post
Post #3





Grupa: Zarejestrowani
Postów: 141
Pomógł: 0
Dołączył: 9.10.2015

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


Nie działa.
Go to the top of the page
+Quote Post
viking
post
Post #4





Grupa: Zarejestrowani
Postów: 6 380
Pomógł: 1116
Dołączył: 30.08.2006

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


http://php.net/manual/pl/simplexmlelement.attributes.php


--------------------
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 21.08.2025 - 11:34