Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> 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
 
Start new topic
Odpowiedzi
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
Go to the top of the page
+Quote Post

Posty w temacie
- ilkar   bledne odczytywanie z xml   14.07.2009, 13:56:47
- - fly474   Hej Zamiast: Kodif ($reader->hasAttr...   14.07.2009, 14:44:56
- - Spawnm   Hey , proszę dodać tagi do tematu   14.07.2009, 15:07:51


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 - 04:56