如何解析这个xml文件?

时间:2012-01-15 18:09:03

标签: java xml ksoap2 kxml2

我正在制作一个包含xml文件内容的测验游戏。我用过java语言

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<LQuiz>
    <Topic id="1" name="About Sun" time="900">
        <question
            name="1. The radiations emitted by the sun and responsible for the cause of skin cancer are...">
            <answer correctness="true">ultra-violet</answer>
            <answer correctness="false">infra-red</answer>
            <answer correctness="false">X-rays</answer>
            <answer correctness="false">micro waves</answer>
            <advice>One of two first</advice>
        </question>
        <question name="2. The source of energy of the sun is...">
            <answer correctness="false">nuclear fission</answer>
            <answer correctness="false">chemical reaction</answer>
            <answer correctness="true">nuclear fusion</answer>
            <answer correctness="false">photoelectric effect</answer>
            <advice>no prompt</advice>
        </question>     
    </Topic>
    <Topic id="2" name="Natural Resources" time="600">
        <question name="1. What are some examples of Non-Renewable Resources?">
            <answer correctness="true">Coal</answer>
            <answer correctness="true">Oil</answer>
            <answer correctness="false">Biomass</answer>
            <advice>no prompt</advice>
        </question>
        <question name="2. What are some alternative sources of energy?">
            <answer correctness="true">Wind</answer>
            <answer correctness="true">Hydro</answer>
            <answer correctness="false">Natural gas</answer>
            <answer correctness="true">Fusion</answer>
            <advice>Select correct variants</advice>
        </question>
         </Topic>
</LQuiz>

有人可以帮我解决如何使用kxmls或ksoaps解析这个xml文件吗?对不起,如果这是一个糟糕的问题。我需要一个示例代码。

1 个答案:

答案 0 :(得分:0)

ksoap2-android项目的wiki有a number of links,可以解释一切。如果您有详细问题,请在此处或项目邮件列表中提出另一个问题。