用NSXMLParser解析多个XML文件最简单的方法是什么?

时间:2022-01-13 04:31:59

I have an array with URLs and I have tried just [myParserObject parse] for next URL inside of - (void)parserDidEndDocument: (NSXMLParser *)parser but it says NSXMLParser does not support reentrant parsing.

我有一个带有URL的数组,我尝试了[myParserObject parse]来处理- (void)parserDidEndDocument: (NSXMLParser *)解析器中的下一个URL,但它说NSXMLParser不支持重入解析。

Is there easy way to parse several XMLs?

有简单的方法来解析几个xml吗?

1 个解决方案

#1


-2  

I had same requirement while building my app in Swift. I did this by iterating and parsing URL's :

我在使用Swift开发应用时也有同样的要求。我通过迭代和解析URL:

var parser = NSXMLParser()

    let url1 = "http://www.test1.xml"
    let url2 = "http://www.test2.xml"
    let url3 = "http://www.test3.xml"
    let url4 = "http://www.test4.xml"        
    let urlArray = [url1 , url2, url3, url4]

    for url in urlArray{
        parser = NSXMLParser(contentsOfURL:(NSURL(string: url))!)!
        parser.delegate = self
        parser.parse()
    }

#1


-2  

I had same requirement while building my app in Swift. I did this by iterating and parsing URL's :

我在使用Swift开发应用时也有同样的要求。我通过迭代和解析URL:

var parser = NSXMLParser()

    let url1 = "http://www.test1.xml"
    let url2 = "http://www.test2.xml"
    let url3 = "http://www.test3.xml"
    let url4 = "http://www.test4.xml"        
    let urlArray = [url1 , url2, url3, url4]

    for url in urlArray{
        parser = NSXMLParser(contentsOfURL:(NSURL(string: url))!)!
        parser.delegate = self
        parser.parse()
    }