Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][XML]Co i jak?
Victor152
post
Post #1





Grupa: Zarejestrowani
Postów: 105
Pomógł: 3
Dołączył: 26.02.2008

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


Witam mam taki dokument xml:
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <bans>
  3. <ban type="2" player="SaMoLoN" time="-1" reason="nothing"/>
  4. <ban type="2" player="AaaaaA" time="-1" reason="nothing"/>

I chce w tabelce z niego odcczytać type, player, time i reason.
Proszę o wskazówki.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 559
Pomógł: 6315
Dołączył: 27.12.2004




no dobra, ale patrz jakich funkcji uzywasz:
http://pl2.php.net/manual/pl/domdocument.loadxml.php
I co napisali ze ona robi?

Masz uzyc load()
  1. <?php
  2. $domDocument = new DOMDocument;
  3. $domDocument->load("bans.xml");
  4. $domXPath = new DOMXPath($domDocument);
  5. foreach ($domXPath->query('//ban') as $keyDOM) {
  6. echo $keyDOM->getAttribute('type');
  7. }
  8. ?>

Nawet w przykladzie co ci dawalem byli load(). Kopiowac tez trzeba umiec (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
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: 11.10.2025 - 07:09