[問題] 取得 xml 的tab 和 內容 ...

看板Ajax作者 (月)時間16年前 (2008/05/12 14:38), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/1
請問一下用 javascript 取得內容的問題 假設有一個 xml 內容為 <class> <title>Hello </title> <content>world</content> </class> 而 script 為 var Node = xmlDoc.getElementsByTagName("Class").childNodes; for (var i=0; i<Node.length; i++) { str += "<"+langNode.item(i).nodeName+">"+langNode.item(i).nodeValue; } 請問要怎樣才能得到這樣的結果? <title>Hello <content>world 我想要取得 tag 的名字和它的內容 ... 但是每次取出來都只有 tag 的名稱 像這樣 <title>#text 就是取不到內容....@@ 謝謝 ^^ -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.120.3.16 ※ 編輯: everydate 來自: 59.120.3.16 (05/12 14:48)

05/13 00:45, , 1F
nodeValue改成data看看
05/13 00:45, 1F

05/21 11:49, , 2F
把xml轉為JSON格式再來取值 http://www.thomasfrank.se
05/21 11:49, 2F
文章代碼(AID): #189-NFxo (Ajax)