Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> bledne odczytywanie z xml
ilkar
post
Post #1





Grupa: Zarejestrowani
Postów: 131
Pomógł: 0
Dołączył: 20.08.2007

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


Hej

używam xml reader, z kodem poniżej

CODE
while($reader->read()){
switch ($reader->localName) {
case "preSIEF":
if ($reader->hasAttributes){
$reader->moveToAttribute("id");
$substance[] = $reader->value;
$reader->moveToAttribute("creationDate");
$substance[] = $reader->value;
$reader->moveToAttribute("exportDate");
$substance[] = $reader->value;
}
break;
case "substanceIdentity":

while($reader->read()){
switch ($reader->name) {
case "ECIdentity":
if($reader->depth == '3'){
$reader->moveToFirstAttribute();
$substance[] = $reader->value;
$reader->moveToNextAttribute();
}
break;
case "name":
if($reader->depth == '4'){
$reader->read();
$substance[] = $reader->value;
}
break;
}
}
break;
}
}


moim problemem jest to, ze nie wiem z jakiego powodu, ale petla 2 razy wpisuje mi to samo do macierzy, czyli np w $substance[1] = '111111' i w $substance[2] = '111111'

jak to obejsc?
Go to the top of the page
+Quote Post
askone
post
Post #2





Grupa: Zarejestrowani
Postów: 654
Pomógł: 121
Dołączył: 27.10.2007
Skąd: Poznań, Łódź

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


Hej

Zamiast:
Kod
if ($reader->hasAttributes){
                $reader->moveToAttribute("id");
                $substance[] = $reader->value;
                $reader->moveToAttribute("creationDate");
                $substance[] = $reader->value;
                $reader->moveToAttribute("exportDate");
                $substance[] = $reader->value;
            }


Spróbuj wykorzystać
Kod
if ($reader->hasAttributes){
$substance[] = $reader->GetAttribute("id");
$substance[] = $reader->GetAttribute("creationDate");
$substance[] = $reader->GetAttribute("exportDate");
            }


Więcej info XMLReader::getAttribute

Pozdro

Ten post edytował fly474 14.07.2009, 14:49:04


--------------------
Kliknij jeśli moja odpowiedź Ci pomogła.
askone.pl
Go to the top of the page
+Quote Post
Spawnm
post
Post #3





Grupa: Moderatorzy
Postów: 4 069
Pomógł: 497
Dołączył: 11.05.2007
Skąd: Warszawa




Hey , proszę dodać tagi do tematu smile.gif
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: 20.08.2025 - 04:31