2011-03-20 137 views
1
<methodResponse> 
    <params> 
     <param> 
      <value> 
       <struct> 
        <member> 
         <name>topic_id</name> 
         <value> 
          <string>102</string> 
         </value> 
        </member> 
        <member> 
         <name>topic_title</name> 
         <value> 
          <string>Login test</string> 
         </value> 
        </member> 
       </struct> 
      </value> 
     </param> 
    </params> 
</methodResponse> 

我有這個xml ..如何使用xpath獲取topic_title的值?Objective C,關於xpath的問題

回答

1
/methodResponse 
    /params 
     /param 
     /value 
      /struct 
       /member[name='topic_title'] 
       /value 
        /string 
+1

的NSString *貼子= [[[解析器nodesForXPath:@ 「/ methodResponse/PARAMS/PARAM /值/結構/構件[名= 'TOPIC_TITLE'] /值/串」 錯誤:無] objectAtIndex:0]字符串值]; – codereviewanskquestions 2011-03-20 23:45:21

+0

這對你來說好嗎? – codereviewanskquestions 2011-03-20 23:45:36

+0

@LCYSoft - 對不起,我不知道Objective-C。我只能提供可以測試的XPath,例如:http://www.xmlme.com/XpathTool.aspx – 2011-03-20 23:51:37