2011-07-11 86 views
0

我正在開發一個應用程序,我需要在這個XML中解析一個XML我不知道有多少元素。如果我點擊任何元素他們的子元素&也我不知道多少元素在這個子部分我也不知道多少子部分動態XML解析

這裏是可能的樣本XML可以沒有人開發的應用程序動態解析

<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> 

回答

0

我完全同意Gomathi,以及那些你必須看到的鏈接query writting

你一些示例代碼..

xPathQuery.h 將xPathQuery.h和xPathQuery.m在您的項目後,您只需撥打

的NSArray *結果= PerformXMLXPathQuery(yourxmlDataObject,給XPathQuery);

你會得到結果數組。所有最好的