![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 160 Pomógł: 4 Dołączył: 22.04.2006 Skąd: Kraków Ostrzeżenie: (0%) ![]() ![]() |
Mam mały problem z parsowaniem xml-a.
Mam pięć elementów w xml-u a musze podać że mam 10 i krok pętli zwiększyć do 2, żeby 'skakała' co 2. Nie rozumiem dlaczego sie tak dzieje (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) Poniżej daje kod. Kod function getHTML() { var url = 'test.xml'; var myAjax = new Ajax.Request( url, { onComplete: showResponse }); } function showResponse(originalRequest) { //$('mails').innerHTML = originalRequest.responseText; d = $("mails"); record = originalRequest.responseXML.getElementsByTagName("record"); for (i = 0; i < record.length; i++) { tr = document.createElement("tr"); td = document.createElement("td"); for (j = 1; j < 10; j+=2) { // w tej linii musiałem podwoić krok pętli td = document.createElement("td"); td.innerHTML = record[i].childNodes[j].childNodes[0].nodeValue; tr.appendChild(td); } d.appendChild(tr); } } test.xml
Dodam że problem jest chyba w przeglądarkach innych niż ie Ten post edytował yaro 30.07.2006, 17:57:25 |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 160 Pomógł: 4 Dołączył: 22.04.2006 Skąd: Kraków Ostrzeżenie: (0%) ![]() ![]() |
Zrobiłem coś takiego ale niestety dalej nie działa (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)
Szukałem w kursie Javascript Cookbook i tam było coś podobnego i na podstawie tego co było w kursie to zrobiłem to, ale nie dokońca dobrze (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg) Prosze o pomoc, bo już nie mam sił Kod function showResponse(originalRequest)
{ d = $("mails"); record = originalRequest.responseXML.getElementsByTagName("record"); for (i = 0; i < record.length; i++) { tr = document.createElement("tr"); for (j = 0; j < record[i].childNodes.length; j++) { if (record[i].childNodes[j].nodeType != 1) { record[i].removeChild(record.childNodes[record.childNodes.length - 1]); } else { td = document.createElement("td"); td.innerHTML = record[i].childNodes[j].firstChild.nodeValue; tr.appendChild(td); } } d.appendChild(tr); } } |
|
|
![]() ![]() |
![]() |
Aktualny czas: 6.10.2025 - 00:17 |