Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript][XML]Pobieranie z xml
czernin
post 26.08.2012, 18:01:27
Post #1





Grupa: Zarejestrowani
Postów: 62
Pomógł: 0
Dołączył: 14.06.2012

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


Mógłby mi ktoś wytłumaczyć, dlaczego to nie chce działać?

  1. <!DOCTYPE html>
  2. <h1>Posty</h1>
  3. <div>
  4. <b>Autor:</b> <span id="author"></span><br />
  5. <b>Data:</b> <span id="updated"></span><br />
  6. <b>Treść postu:</b> <span id="title"></span>
  7. </div>
  8.  
  9. <script type="text/javascript">
  10. if (window.XMLHttpRequest)
  11. {// code for IE7+, Firefox, Chrome, Opera, Safari
  12. xmlhttp=new XMLHttpRequest();
  13. }
  14. else
  15. {// code for IE6, IE5
  16. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  17. }
  18. xmlhttp.open("GET","http://exploration-base.blogspot.com/feeds/posts/default",false);
  19. xmlhttp.send();
  20. xmlDoc=xmlhttp.responseXML;
  21.  
  22. document.getElementById("author").innerHTML=
  23. xmlDoc.getElementsByTagName("author")[0].childNodes[0].nodeValue;
  24. document.getElementById("updated").innerHTML=
  25. xmlDoc.getElementsByTagName("updates")[0].childNodes[0].nodeValue;
  26. document.getElementById("message").innerHTML=
  27. xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;
  28.  
  29. </body>
  30. </html>


Kod
http://exploration-base.blogspot.com/feeds/posts/default


- Tam plik xml...
Go to the top of the page
+Quote Post
darko
post 26.08.2012, 18:24:19
Post #2





Grupa: Zarejestrowani
Postów: 2 885
Pomógł: 463
Dołączył: 3.10.2009
Skąd: Wrocław

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


"Wyalertuj" zmienną xmlDoc, dodatkowo przejrzyj zakładkę net w firebugu i zobacz status żądania. Plus w metodzie open zrezygnuj z drugiego argumentu, który jest tylko dla żądań typu post.

Ten post edytował darko 26.08.2012, 18:27:33


--------------------
Nie pomagam na pw, tylko forum.
Go to the top of the page
+Quote Post
czernin
post 26.08.2012, 18:30:36
Post #3





Grupa: Zarejestrowani
Postów: 62
Pomógł: 0
Dołączył: 14.06.2012

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


Ten skrypt doskonale działał, gdy zamiast "http://exploration-base.blogspot.com/feeds/posts/default" był "kod.xml". Wtedy było ok..
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 Wersja Lo-Fi Aktualny czas: 25.07.2025 - 09:51