我有希望從中獲取值這個XML文件:使用JavaScript從xml文件中獲取文本值?
<test>
<item>
<question audio='audio/AB2001Q.mp3' category='Alertness'>Before you make a U-turn in the road, you should</question>
<description audio='audio/s1,1.mp3'>If you want to make a U-turn, slow down and ensure that the road is clear in both directions. Make sure that the road is wide enough to carry out the manoeuvre safely.</description>
<image ></image>
<answers>
<answer title='a' audio='audio/AB2001A.mp3'>give an arm signal as well as using your indicators</answer>
<answer title='b' audio='audio/AB2001B.mp3'>signal so that other drivers can slow down for you</answer>
<answer title='c' audio='audio/AB2001C.mp3'>look over your shoulder for a final check</answer>
<answer title='d' audio='audio/AB2001D.mp3'>select a higher gear than normal</answer>
</answers>
<correctAnswers>
<answer>c</answer>
</correctAnswers>
</item>
</test>
我怎樣才能得到問題的音頻的文字內容和問題文本,以便例如
「音頻/ AB2001Q.mp3」是問題的音頻
「以前大家做一個掉頭的道路,就應該」是疑問句
這是我到目前爲止有:
var doc = Ti.XML.parseString(blob);
var branch = doc.getElementsByTagName('item').item(0);
我對xml很陌生!
您是否在'parseString(blob)'後面忘記';'? –
對不起,修復它我正在使用coffeescript多數民衆贊成在爲什麼:) – unknown