开发者

Parsing XML for nested tags

I have an XML, I am getting data into the format as below :

<Question>
    <QuestionID>1</QuestionID>
    <QuestionType>Logic</QuestionType>
    <QuestionImage>http://mobilecms.hiteshi.com/IQ/xml/Logic/1/Question/q.jpg</QuestionImage>
    <QuestionText>1 Which is the Next image?</QuestionText>
    <AnswerImages Count="4">
        <Image>http://mobilecms.hiteshi.com/IQ/xml/Logic/1/Answer/a.jpg</Image>
        <Image>http://mobilecms.hiteshi.com/IQ/xml/Logic/1/Answer/开发者_Python百科b.jpg</Image>
        <Image>http://mobilecms.hiteshi.com/IQ/xml/Logic/1/Answer/c.jpg</Image>
        <Image>http://mobilecms.hiteshi.com/IQ/xml/Logic/1/Answer/d.jpg</Image>
    </AnswerImages>
    <Answer>d</Answer>
    <Score>1</Score>
    <DifficultyLevel>1</DifficultyLevel>
</Question>

I have to read that XML and store all tags data into Two different tables of sqlite. I can easily read Main tags like QuestionID, QuestionType etc, and stores it into tableOne.

Now I want to read AnswerImages tag which is having count into it and it contents child tag named <Image> according to that count variable. Here I want to store all the <Image> tag data into tableTwo.

How can I store data into tableOne and tableTwo simultaneously?


On an abstract level (without regarding any specific platform) you would deserialize your Xml to an object which then can be persisted to database by a Object-Relational-Mapper framework.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜