1

我使用了一个使用 touchXML 并解析特定网站的在线教程,以便它为我提供所有元素及其值

// Convert the supplied URL string into a usable URL object

    NSURL *url = [NSURL URLWithString: blogAddress];

// Create a new rssParser object based on the TouchXML "CXMLDocument" class, this is the
// object that actually grabs and processes the RSS data

    CXMLDocument *rssParser = [[[CXMLDocument alloc] initWithContentsOfURL:url options:0 error:nil] autorelease];

// Create a new Array object to be used with the looping of the results from the rssParser

    NSArray *resultNodes = NULL;

// Set the resultNodes Array to contain an object for every instance of an  node in our RSS feed

    resultNodes = [rssParser nodesForXPath:@"//item" error:nil];

// Loop through the resultNodes to access each items actual data

 for (CXMLElement *resultElement in resultNodes) {

    // Create a temporary MutableDictionary to store the items fields in, which will eventually end up in blogEntries

 NSMutableDictionary *blogItem = [[NSMutableDictionary alloc] init];

    // Create a counter variable as type "int"

 int counter;

    // Loop through the children of the current  node
    for(counter = 0; counter < [resultElement childCount]; counter++) {

        // Add each field to the blogItem Dictionary with the node name as key and node value as the value
        [blogItem setObject:[[resultElement childAtIndex:counter] stringValue] forKey:[[resultElement childAtIndex:counter] name]];

    }

    // Add the blogItem to the global blogEntries Array so that the view can access it.
    [blogEntries addObject:[blogItem copy]];

现在,因为我在 blogEntries mutableDictionary 中拥有所有数据,所以我有一个标签对象和顶部的 2 个条形按钮项目,然后 我真正想要做的是

1)点击下一步使用相同的标签对象并从 blogEntries mutableDictionary 加载下一个数据

2)点击返回使用相同的标签对象并从 blogEntries mutableDictionary 加载以前的数据

如果假设有人除了在不使用栏按钮项目的情况下加载新内容之外还有其他想法,那么欢迎您,我的项目基本上处理 rss 提要,所以我要做的就是通过单击下一步或使用滑动手势浏览下一个新闻。 。谢谢

4

0 回答 0