如何使用GetElementsByTagName读取XML [英] how to read XML by using GetElementsByTagName

查看:134
本文介绍了如何使用GetElementsByTagName读取XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里需要帮助。


这是我的XML文件。


< kelvin>

< ;模块分配=" 1" questionno。=" 0">

< question> asd< / question>

< choice1> 1< / choice1>

< choice2> 2< / choice2>

< choice3> 3< / choice3>

< choice4> 4< / choice4>

< correctchoice>选择2< / correctchoice>

< / module>

< module assignment =" 1" questionno。=" 1">

< question> asdasd< / question>

< choice1> 11< / choice1>

< choice2> 22< / choice2>

< choice3> 33< / choice3>

< choice4> 44< / choice4>

< correctchoice>选择2< / correctchoice>

< / module>

< module assignment =" 1" questionno。=" 2">

< question> dsfsdf< / question>

< choice1> 111< / choice1>

< choice2> 222< / choice2>

< choice3> 333< / choice3>

< choice4> 444< / choice4>

< correctchoice>选择3< / correctchoice>

< / module>

< / kelvin>



显示问题标签上的问题。

在choice1标签上显示Choice1。

在choice2标签上显示Choice2。


我已经尝试了,但我的标签显示了该特定元素中的每一个。


请帮助我。

谢谢。

need help here.

here is my XML file.

<kelvin>
<module assignment="1" questionno.="0">
<question>asd</question>
<choice1>1</choice1>
<choice2>2</choice2>
<choice3>3</choice3>
<choice4>4</choice4>
<correctchoice>Choice 2</correctchoice>
</module>
<module assignment="1" questionno.="1">
<question>asdasd</question>
<choice1>11</choice1>
<choice2>22</choice2>
<choice3>33</choice3>
<choice4>44</choice4>
<correctchoice>Choice 2</correctchoice>
</module>
<module assignment="1" questionno.="2">
<question>dsfsdf</question>
<choice1>111</choice1>
<choice2>222</choice2>
<choice3>333</choice3>
<choice4>444</choice4>
<correctchoice>Choice 3</correctchoice>
</module>
</kelvin>


display question at question label.
display Choice1 at choice1 label.
display Choice2 at choice2 label.

i''ve tried, but my label display everyting in that particular element.

please help me.
Thank You.

推荐答案

你使用DOM或XSLT进行转换吗?


关于
do you use DOM or XSLT to do the transformation?

regards


XSLT进行转换。
XSLT for the transformation.


输出文件应该是什么样的?
what shall the output file look like?


这篇关于如何使用GetElementsByTagName读取XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆