1

我正在尝试使用touchXml解析下面给出的 xml ,我搜索并发现它正在使用名称空间,因此我需要使用名称空间来解析该 xml。但是任何人都可以指导我获取条目标签的所有子记录的确切名称空间。我尝试了很多组合,但我认为我不明白如何获取条目标签数据。

<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0">
<id>tag:blogger.com,1999:blog-2497739505751584707</id>
<updated>2012-03-16T22:56:53.663-07:00</updated>
<title type="text">Recipes</title>
<subtitle type="html" />
<link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://acaiberryrecipes.blogspot.com/feeds/posts/default" />
<link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2497739505751584707/posts/default" />
<link rel="alternate" type="text/html" href="http://acaiberryrecipes.blogspot.com/" />
<link rel="hub" href="http://pubsubhubbub.appspot.com/" />
<link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/2497739505751584707/posts/default?start-index=26&max-results=25" />
<author>
    <name>default.com</name>
    <uri>http://www.blogger.com/profile/05035355929944075160</uri>
    <email>noreply@blogger.com</email>
    <gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://www.allauthentic.com/images/aalogo.gif" width="29" />
</author>
<generator version="7.00" uri="http://www.blogger.com">Blogger</generator>
<openSearch:totalResults>64</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>25</openSearch:itemsPerPage>
<entry>
    <id>tag:blogger.com,1999:blog-2497739505751584707.post-5806304525333943936</id>
    <published>2010-01-05T12:09:00.001-08:00</published>
    <updated>2010-01-16T00:36:01.451-08:00</updated>
    <title type="text">Welcome To Amazon Thunder! Check out our free recipes (updated), shopping list, easy ordering, and more! Please give us 5 stars in the app store</title>
    <content type="html" />
    <link title="Post Comments" rel="replies" type="application/atom+xml" href="http://acaiberryrecipes.blogspot.com/feeds/5806304525333943936/comments/default" />
    <link title="0 Comments" rel="replies" type="text/html" href="http://acaiberryrecipes.blogspot.com/2010/01/welcome-to-amazon-thunder-on-your.html#comment-form" />
    <link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2497739505751584707/posts/default/5806304525333943936" />
    <link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2497739505751584707/posts/default/5806304525333943936" />
    <link title="Welcome To Amazon Thunder! Check out our free recipes (updated), shopping list, easy ordering, and more! Please give us 5 stars in the app store" rel="alternate" type="text/html" href="http://acaiberryrecipes.blogspot.com/2010/01/welcome-to-amazon-thunder-on-your.html" />
    <author>
        <name>ALLAuthentic.com</name>
        <uri>http://www.blogger.com/profile/05035355929944075160</uri>
        <email>noreply@blogger.com</email>
        <gd:image height="32" rel="http://schemas.google.com/g/2005#thumbnail" src="http://www.allauthentic.com/images/aalogo.gif" width="29" />
    </author>
    <thr:total>0</thr:total>
</entry>
4

2 回答 2

0

您的默认命名空间(这是似乎使用的条目http://www.w3.org/2005/Atom)由以下内容指定:

xmlns="http://www.w3.org/2005/Atom"
于 2013-11-10T18:54:41.783 回答
0

NSDictionary *nameSpace=[NSDictionary dictionaryWithObjectsAndKeys:@" http://www.w3.org/2005/Atom ",@"xmlns",@" http://www.georss.org/georss ",@"georss", @" http://a9.com/-/spec/opensearchrss/1.0/ ",@"openSearch",@" http://schemas.google.com/blogger/2008 ",@"blogger",@" http ://schemas.google.com/g/2005 ",@"gd", @" http://purl.org/syndication/thread/1.0",@"thr", nil]; resultNodes=[xmlDoc nodesForXPath:@"//xmlns:feed//xmlns:entry" namespaceMappings:nameSpace error:&error];

于 2013-11-04T06:41:58.093 回答