Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在iOS中解析XML结束标记(目标C)?_Ios_Objective C_Xml_Xml Parsing - Fatal编程技术网

在iOS中解析XML结束标记(目标C)?

在iOS中解析XML结束标记(目标C)?,ios,objective-c,xml,xml-parsing,Ios,Objective C,Xml,Xml Parsing,我想从xml响应中识别结束标记。比如说, <ItemLocationResponse xxxx> <UserProfile> blah blah contents.. </UserProfile> <UserProfile> blah blah contents.. </UserProfile> </ItemLocationResponse> 诸如此类的内容

我想从xml响应中识别结束标记。比如说,

<ItemLocationResponse xxxx>
    <UserProfile>
        blah blah contents..
    </UserProfile>
    <UserProfile>
        blah blah contents..
    </UserProfile>
</ItemLocationResponse>

诸如此类的内容。。
诸如此类的内容。。

我想确定结束标记。目前,我能够解析包含在开始标记中的数据。从上面的示例中,我可以解析每个开始标记中“blah blah contents”中包含的数据。为了得到结束标记以标识xml响应已经结束,我做了很多工作。那么,我如何才能识别结束标记已被提交?

简单易用。

您可以在iOS中使用
NSXMLParser
进行xml解析

NSXMLParser * parser = [[NSXMLParser alloc] initWithData:data];
[parser setDelegate:self];
[parser parse];
实现其委托方法以获取xml元素

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
//Called when any element which having opening and closing element and its closed called

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
//if tag having value then this method is called.

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string

- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError

你是说获取XML属性吗?()您使用的是解析器还是自己定制的解决方案?为什么?