【问题标题】:Objective C, A Question about xpathObjective C,一个关于 xpath 的问题
【发布时间】:2011-03-20 23:35:30
【问题描述】:
<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 touchxml


    【解决方案1】:
    /methodResponse
       /params
          /param
             /value
                /struct
                  /member[name='topic_title']
                     /value
                        /string
    

    【讨论】:

    • NSString *postings = [[[parser nodesForXPath:@"/methodResponse/params/param/value/struct/member[name='topic_title']/value/string" error:nil] objectAtIndex: 0] 字符串值];
    • @LCYSoft - 抱歉,我不知道 Objective-C。我只能提供XPath,你可以测试一下,比如这里:xmlme.com/XpathTool.aspx
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-28
    • 1970-01-01
    • 1970-01-01
    • 2011-11-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多