Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [XML] Jaka forma danych zwracanych przez XML jest lepsza?
miedzna
post 23.04.2008, 08:40:47
Post #1





Grupa: Zarejestrowani
Postów: 401
Pomógł: 1
Dołączył: 10.03.2004
Skąd: Warszawa

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


Chcę do XMLa przekazać dane, które później javascriptem będą wyświetlane na stronie, czyli ajax.
W związku z czym mam pytanie, lepiej zwrócić xmla w formie A:

  1. <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
  2. <link>
  3. <Href>http://www.onet.pl/</Href>
  4. <Text>onet</Text>
  5. </link>


czy w formie B:

  1. <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
  2. <link>
  3. <tresc><a href="http://www.onet.pl/">onet</a></tresc>
  4. </link>
Go to the top of the page
+Quote Post
batman
post 23.04.2008, 09:12:44
Post #2





Grupa: Moderatorzy
Postów: 2 921
Pomógł: 269
Dołączył: 11.08.2005
Skąd: 127.0.0.1




Ja bym wybrał ukrytą opcję C winksmiley.jpg
  1. <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
  2. <links>
  3.    <link href="http://www.onet.pl/">onet</link>
  4.    <link href="http://www.wp.pl/">wp</link>
  5. </links>


--------------------
I would love to change the world, but they won't give me the source code.
My software never has bugs. It just develops random features.
Go to the top of the page
+Quote Post
webdice
post 23.04.2008, 10:34:52
Post #3


Developer


Grupa: Moderatorzy
Postów: 3 045
Pomógł: 290
Dołączył: 20.01.2007




Uważam że nie powinno się wstawiać tagów HTML do XML'a.
Go to the top of the page
+Quote Post
batman
post 23.04.2008, 10:47:36
Post #4





Grupa: Moderatorzy
Postów: 2 921
Pomógł: 269
Dołączył: 11.08.2005
Skąd: 127.0.0.1




Tagi można, a czasami nawet powinno się wstawiać do plików XML (np w szablonach), należy jednak pamiętać, by użyć cdata.


--------------------
I would love to change the world, but they won't give me the source code.
My software never has bugs. It just develops random features.
Go to the top of the page
+Quote Post
miedzna
post 25.04.2008, 12:17:09
Post #5





Grupa: Zarejestrowani
Postów: 401
Pomógł: 1
Dołączył: 10.03.2004
Skąd: Warszawa

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


Cytat(batman @ 23.04.2008, 10:12:44 ) *
Ja bym wybrał ukrytą opcję C winksmiley.jpg
  1. <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
  2. <links>
  3.    <link href="http://www.onet.pl/">onet</link>
  4.    <link href="http://www.wp.pl/">wp</link>
  5. </links>


No dobra, wydaje mi się, że wiem jak pobrać linka i treść:

  1. link = getElementsByTagName("links").getAttribute("href");
  2. tresc = getElementsByTagName("links")[0].childNodes[0].nodeValue;

dobrze?

ale jak pobrać i umieścić w "document.getElementById("links").innerHTML=" jeżeli tych linków będzie 10?
Pętlą for? Ale jak?
tak, ale co dalej, jak to umieścić w "document.getElementById("links").innerHTML=" questionmark.gif?
  1. for(var i = 0; i <= getElementsByTagName("links").length; i++){
  2. var link = getElementsByTagName("links")[0].getAttribute("href");
  3. var tresc = getElementsByTagName("links")[0].childNodes[0].nodeValue;
  4. }


Ten post edytował miedzna 25.04.2008, 12:18:41
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: 6.07.2025 - 13:05