本文介绍了动态XML解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,其中我需要解析此XML中的一个XML我不知道有多少元素。如果我点击任何元素他们是子元素&另外我不知道这个子节中有多少元素另外我不知道子节有多少

i am developing one app in which i need to parse one XML in this XML i don't know how much Element. and if i click on any element their is sub element & also i don't know how much element in this sub section Also i don't know how much sub section

这里可能是样本XML可以为一个开发的应用程序动态解析

here is may sample XML can nay one developed app for dynamic parsing

    <subject>
<subject_count>5</subject_count>
<subject_image>http://50.17.184.57/wm911/index4.jpeg</subject_image>
<subject_name>MCA</subject_name>
<subject_image>http://50.17.184.57/wm911/index4.jpeg</subject_image>
<subject_name>BCA</subject_name>
<subject_image>http://50.17.184.57/wm911/index4.jpeg</subject_image>
<subject_name>BSc</subject_name>
<subject_image>http://50.17.184.57/wm911/index4.jpeg</subject_image>
<subject_name>engg</subject_name>
<subject_image>http://50.17.184.57/wm911/index4.jpeg</subject_image>
<subject_name>BBA</subject_name>
<subject>




<topic>

<topic1>
<topic_count>3</topic_count>
<topic_image>http://50.17.184.57/wm911/index4.jpeg</topic_image>
<topic_name>Adv C</topic_name>
<topic_image>http://50.17.184.57/wm911/index4.jpeg</topic_image>
<topic_name>Objective C</topic_name>
<topic_image>http://50.17.184.57/wm911/index4.jpeg</topic_image>
<topic_name>Java</topic_name>
</topic1>

<topic2>
<topic_count>4</topic_count>
<topic_image>http://50.17.184.57/wm911/index4.jpeg</topic_image>
<topic_name>C</topic_name>
<topic_image>http://50.17.184.57/wm911/index4.jpeg</topic_image>
<topic_name>C++</topic_name>
<topic_image>http://50.17.184.57/wm911/index4.jpeg</topic_image>
<topic_name>.Net</topic_name>
<topic_image>http://50.17.184.57/wm911/index4.jpeg</topic_image>
<topic_name>network</topic_name>
</topic2>


<topic3>
<topic_count>2</topic_count>
<topic_image>http://50.17.184.57/wm911/index4.jpeg</topic_image>
<topic_name>sic</topic_name>
<topic_image>http://50.17.184.57/wm911/index4.jpeg</topic_image>
<topic_name>computer</topic_name>
</topic3>



<topic4>
<topic_count>2</topic_count>
<topic_image>http://50.17.184.57/wm911/index4.jpeg</topic_image>
<topic_name>math</topic_name>
<topic_image>http://50.17.184.57/wm911/index4.jpeg</topic_image>
<topic_name>Adv computers</topic_name>
 </topic4>


<topic5>
<topic_count>1</topic_count>
<topic_image>http://50.17.184.57/wm911/index4.jpeg</topic_image>
<topic_name>management</topic_name>
 </topic5>

 </topic>





  <sub_topic>

  <topic1.1>
  <sub_topic_count>2</sub_topic_count>
<sub_topic_image>http://50.17.184.57/wm911/index4.jpeg</sub_topic_image>
<sub_topic_name>C program</sub_topic_name>
<sub_topic_image>http://50.17.184.57/wm911/index4.jpeg</sub_topic_image>
<sub_topic_name>system programing</sub_topic_name>
  </topic1.1>


 <topic1.2>
 <sub_topic_count>3</sub_topic_count>
<sub_topic_image>http://50.17.184.57/wm911/index4.jpeg</sub_topic_image>
<sub_topic_name>XML parsing</sub_topic_name>
<sub_topic_image>http://50.17.184.57/wm911/index4.jpeg</sub_topic_image>
<sub_topic_name>Table</sub_topic_name>
<sub_topic_image>http://50.17.184.57/wm911/index4.jpeg</sub_topic_image>
<sub_topic_name>ipad</sub_topic_name>
  </topic1.2>


  <topic1.3>
  <sub_topic_count>2</sub_topic_count>
<sub_topic_image>http://50.17.184.57/wm911/index4.jpeg</sub_topic_image>
<sub_topic_name>Java1</sub_topic_name>
<sub_topic_image>http://50.17.184.57/wm911/index4.jpeg</sub_topic_image>
<sub_topic_name>java2</sub_topic_name>
  </topic1.3>


  <topic2.1>
  <sub_topic_count>2</sub_topic_count>
<sub_topic_image>http://50.17.184.57/wm911/index4.jpeg</sub_topic_image>
<sub_topic_name>POP</sub_topic_name>
<sub_topic_image>http://50.17.184.57/wm911/index4.jpeg</sub_topic_image>
<sub_topic_name>basic C</sub_topic_name>
 </topic2.1>


 <topic2.2>
 <sub_topic_count>2</sub_topic_count>
<sub_topic_image>http://50.17.184.57/wm911/index4.jpeg</sub_topic_image>
<sub_topic_name>OOP</sub_topic_name>
<sub_topic_image>http://50.17.184.57/wm911/index4.jpeg</sub_topic_image>
<sub_topic_name>basic C++</sub_topic_name>
  </topic2.2>

  <topic2.3>
  <sub_topic_count>3</sub_topic_count>
<textname>  TEXT1  </textname>  <sub_topic_image>http://50.17.184.57/wm911/index4.jpeg</sub_topic_image>
<sub_topic_name>.Net2</sub_topic_name>
<video_url>http://192.168.1.128/xml/video/Citizen_7_Trailer_Mayor_09_07_10.m4v </video_url>
</topic2.3>

<topic2.4>
<sub_topic_count>2</sub_topic_count>
    <pdf_url>http://50.17.184.57/wm911/STTcourse.pdf<pdf_url>
    <ppt_url>http://192.168.1.128/xml/doc/PPT_SAMPLE.ppt </ppt_url>

</topic2.4>

</sub_topic>


推荐答案

您可以使用libxml2来解析xml文件或文档。
Pl。请参阅以下链接以供参考。

You can use libxml2 to parse the xml file or document.Pl. see the following link for reference.

你也可以在google中搜索libxml2来解析文件。

Also u can search for libxml2 in google to parse the file.

我建议。

这篇关于动态XML解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 11:11