带有名字空间(xmlns)的解析问题

    <message xmlns="jabber:client" id="aeOfp-7" to="43@chisalsoft" from="73@localhost123/Smack" type="chat">
    <body>CoverImagePath</body>
    <thread>LsNnJ2</thread>
    <properties xmlns="http://www.jivesoftware.com/xmlns/xmpp/properties">
    <property>
    <name>CoverImagePath</name>
    <value type="string">image/2014/6/18/17/27/37/1405675657646.jpg</value>
    </property>
    </properties>
    </message>

首先放上xml,这个是xmpp message的xml格式,想要获取 <value type="string">image/2014/6/18/17/27/37/1405675657646.jpg</value>,但是通过 NSString *xpath = @"/message/properties/property/value"这个路径始终无法正确获得,最终google了很久,发现问题出现 xmlns上……


解决方法不是我自己想出来的,而是google找到的,忘记了文章的地址了(抱歉了)


NSString *NoXmlsString  = [message.description stringByReplacingOccurrencesOfString:@"xmlns" withString:@"noNSxml"];

就是把xmlns替换成别的字符,这样就可以愉快的解析了……………………


写下这篇日志,主要是为了记录,顺便帮助下遇到相同问题的其他人……


有什么错误的地方还请提出。。。。。

posted on 2014-07-22 09:40  超级庄子  阅读(220)  评论(0编辑  收藏  举报

导航