解析具有名称空间的xml

时间:2013-11-01 11:27:45

标签: ios iphone objective-c touchxml

我正在尝试使用 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>

2 个答案:

答案 0 :(得分: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”,@ “博主”,                                        @ “http://schemas.google.com/g/2005”,@ “GD”,                                        @ “http://purl.org/syndication/thread/1.0”,@ “THR”,                                         零];     resultNodes = [xmlDoc nodesForXPath:@“// xmlns:feed // xmlns:entry”namespaceMappings:nameSpace error:&amp; error];

答案 1 :(得分:0)

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

xmlns="http://www.w3.org/2005/Atom"