iphone - TouchXML 命名空间解析?
<p><p>我正在尝试通过 TouchXML 解析以下 XML:</p>
<pre><code><s:Envelope xmlns:s="namespace_1">
<s:Body>
<DefinedEntitiesResponse xmlns="namespace_2">
<DefinedEntitiesResult xmlns:a="namespace_3" xmlns:i="namespace_4">
<a:DefinedEntity>
<a:Description>Some Description</a:Description>
<a:Name>Some entity name</a:Name>
</a:DefinedEntity>
</DefinedEntitiesResult>
</DefinedEntitiesResponse>
</s:Body>
</s:Envelope>
</code></pre>
<p>我尝试这样解析:</p>
<pre><code>CXMLDocument *doc = [[ initWithXMLString: options:0 error:nil] autorelease];
NSArray *resultNodes = ;
NSLog(@"Resultnodes: %@", resultNodes);
</code></pre>
<p>得到错误:</p>
<pre><code>XPath error : Undefined namespace prefix
XPath error : Invalid expression
</code></pre>
<p>问题 1:我做错了什么?
问题 2:我应该使用 TouchXML 作为库,还是有更简单更好的方法?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>使用以下 <a href="https://github.com/Insert-Witty-Name" rel="noreferrer noopener nofollow">project on github</a>将您的 XML 解析为 NSDictionary。然后,您可以使用 <code>NSPredicate</code> 在已解析的字典中查找值。</p></p>
<p style="font-size: 20px;">关于iphone - TouchXML 命名空间解析?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/7713104/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/7713104/
</a>
</p>
页:
[1]