2011-09-26 94 views
-1

嗨,我需要分析其結構爲的NSXMLParser如下所示的XML文件,如何解析我的嵌套xml?

<Root> 
    <Ancor> 
     <A1>,,,,,,,</A1> 
     <A2>,,,,,,,</A2> 
     <A3>,,,,,,,</A3> 
     <subContent> 
      <![CDATA[,,,,,,,,,,,,,,,,,,,]]? 
     </subContent> 
    </Ancor> 

    <Main id="1"> 
     <Basic>,,,,,,,</Basic> 
     <Info> 
      <info1>,,,,,,</info1> 
      <info2>,,,,,,</info2> 
      <info3>,,,,,,</info3> 
      <subInfo id="1"> 
       <subcontent1>,,,,,,</subcontent1> 
        <subcontent2>,,,,,,</subcontent2> 
      </subInfo> 
      <html> 
       <![CDATA[,,,,,,,,,,,,,,,,]]> 
      </html> 
     </Info> 
    </Mainid> 
</Root> 

這裏稱爲根N主標籤的數量主要標籤內將陸續根據不同的不同的ID,每個主標籤內容我需要存儲和顯示在1頁。 任何人都可以幫助一些代碼片段?,任何幫助提前感謝,謝謝。

+0

的可能重複[如何讀取和解析iPhone上的XML文件?](http://stackoverflow.com/questions/2097631/how-to-read-in-and-parse-an-xml-file-on-the-iphone) –

+0

另請參見:[ 1](http://stackoverflow.com/questions/2237757/cocoa-objective-c-best-practice-to-parse-xml-document)[2](http://stackoverflow.com/questions/3729514/sending -and-receiving-xml-to-and-from-server-using-cocoa)[3](http://stackoverflow.com/questions/2964503/nsxmlparser-on-the-iphone-how-do-i-use -it-given-a-xml-file-newb-here)[4](http://stackoverflow.com/questions/3731453/parsing-xml-in-cocoa)[5](http://stackoverflow.com/questions/3731594 /)[6 ](http://stackoverflow.com/questions/5274513/)[等等...](http://stackoverflow.com/search?q=%5Bobjc%5D+xml+file+parse) –

回答

1

XMLParser中可以檢測自己的標籤..所有你需要做的是在代表比較標籤和獲取值了...希望這有助於..

+0

+1投票給你的用戶名;) – Devarshi