我有Web服务返回XML,我使用NSXMLParser从XML获取值。 这是我的代码:
//---when the start of an element is found---
-(void) parser:(NSXMLParser *) parser didStartElement:(NSString *) elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *) qName attributes:(NSDictionary *)attributeDict {
NSLog(@"Start Element : %@",elementName);
}
-(void)parser:(NSXMLParser *) parser foundCharacters:(NSString *)string
{//NSLog(@" parser foundCharacters");
NSLog(@"Found Char : %@",string);
}
-(void)parser:(NSXMLParser *)parser
didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName
{
NSLog(@"End Element : %@",elementName);
}
这是NSXMLParser的输出:
2014-05-01 14:56:03.703 Stats_V2[2647:70b] Start Element : soap:Envelope
2014-05-01 14:56:03.704 Stats_V2[2647:70b] Start Element : soap:Body
2014-05-01 14:56:03.704 Stats_V2[2647:70b] Start Element : GetReportsXMLResponse
2014-05-01 14:56:03.704 Stats_V2[2647:70b] Start Element : GetReportsXMLResult
2014-05-01 14:56:03.705 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.705 Stats_V2[2647:70b] Found Char : Report
2014-05-01 14:56:03.705 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.706 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.706 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.706 Stats_V2[2647:70b] Found Char : Row
2014-05-01 14:56:03.707 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.707 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.707 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.707 Stats_V2[2647:70b] Found Char : Sector
2014-05-01 14:56:03.708 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.708 Stats_V2[2647:70b] Found Char : SSS
2014-05-01 14:56:03.708 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.708 Stats_V2[2647:70b] Found Char : /Sector
2014-05-01 14:56:03.708 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.709 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.709 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.709 Stats_V2[2647:70b] Found Char : V1
2014-05-01 14:56:03.709 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.710 Stats_V2[2647:70b] Found Char : 21
2014-05-01 14:56:03.710 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.710 Stats_V2[2647:70b] Found Char : /V1
2014-05-01 14:56:03.710 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.710 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.711 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.711 Stats_V2[2647:70b] Found Char : V2
2014-05-01 14:56:03.711 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.711 Stats_V2[2647:70b] Found Char : 21
2014-05-01 14:56:03.712 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.712 Stats_V2[2647:70b] Found Char : /V2
2014-05-01 14:56:03.712 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.712 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.712 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.713 Stats_V2[2647:70b] Found Char : V3
2014-05-01 14:56:03.713 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.713 Stats_V2[2647:70b] Found Char : 31
2014-05-01 14:56:03.713 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.714 Stats_V2[2647:70b] Found Char : /V3
2014-05-01 14:56:03.714 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.714 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.714 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.714 Stats_V2[2647:70b] Found Char : /Row
2014-05-01 14:56:03.715 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.715 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.715 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.715 Stats_V2[2647:70b] Found Char : Row
2014-05-01 14:56:03.715 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.716 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.716 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.716 Stats_V2[2647:70b] Found Char : Sector
2014-05-01 14:56:03.716 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.716 Stats_V2[2647:70b] Found Char : dad
2014-05-01 14:56:03.716 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.717 Stats_V2[2647:70b] Found Char : /Sector
2014-05-01 14:56:03.717 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.717 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.717 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.717 Stats_V2[2647:70b] Found Char : V1
2014-05-01 14:56:03.718 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.718 Stats_V2[2647:70b] Found Char : 321
2014-05-01 14:56:03.718 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.718 Stats_V2[2647:70b] Found Char : /V1
2014-05-01 14:56:03.718 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.719 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.719 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.719 Stats_V2[2647:70b] Found Char : V2
2014-05-01 14:56:03.719 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.719 Stats_V2[2647:70b] Found Char : 123
2014-05-01 14:56:03.719 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.720 Stats_V2[2647:70b] Found Char : /V2
2014-05-01 14:56:03.720 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.720 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.720 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.720 Stats_V2[2647:70b] Found Char : V3
2014-05-01 14:56:03.721 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.721 Stats_V2[2647:70b] Found Char : 213
2014-05-01 14:56:03.721 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.721 Stats_V2[2647:70b] Found Char : /V3
2014-05-01 14:56:03.721 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.722 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.722 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.722 Stats_V2[2647:70b] Found Char : /Row
2014-05-01 14:56:03.722 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.722 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.722 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.723 Stats_V2[2647:70b] Found Char : Row
2014-05-01 14:56:03.723 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.723 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.723 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.723 Stats_V2[2647:70b] Found Char : Sector
2014-05-01 14:56:03.723 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.724 Stats_V2[2647:70b] Found Char : das
2014-05-01 14:56:03.724 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.724 Stats_V2[2647:70b] Found Char : /Sector
2014-05-01 14:56:03.724 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.724 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.725 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.725 Stats_V2[2647:70b] Found Char : V1
2014-05-01 14:56:03.725 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.725 Stats_V2[2647:70b] Found Char : 12702
2014-05-01 14:56:03.725 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.725 Stats_V2[2647:70b] Found Char : /V1
2014-05-01 14:56:03.726 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.726 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.726 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.726 Stats_V2[2647:70b] Found Char : V2
2014-05-01 14:56:03.726 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.727 Stats_V2[2647:70b] Found Char : 1270
2014-05-01 14:56:03.727 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.727 Stats_V2[2647:70b] Found Char : /V2
2014-05-01 14:56:03.727 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.727 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.728 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.728 Stats_V2[2647:70b] Found Char : V3
2014-05-01 14:56:03.728 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.728 Stats_V2[2647:70b] Found Char : 13972
2014-05-01 14:56:03.728 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.728 Stats_V2[2647:70b] Found Char : /V3
2014-05-01 14:56:03.729 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.729 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.729 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.729 Stats_V2[2647:70b] Found Char : /Row
2014-05-01 14:56:03.729 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.730 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.730 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.730 Stats_V2[2647:70b] Found Char : Row
2014-05-01 14:56:03.730 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.730 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.731 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.731 Stats_V2[2647:70b] Found Char : Sector
2014-05-01 14:56:03.731 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.731 Stats_V2[2647:70b] Found Char : sdeqe
2014-05-01 14:56:03.731 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.732 Stats_V2[2647:70b] Found Char : /Sector
2014-05-01 14:56:03.732 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.732 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.732 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.732 Stats_V2[2647:70b] Found Char : V1
2014-05-01 14:56:03.732 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.733 Stats_V2[2647:70b] Found Char : 3305
2014-05-01 14:56:03.733 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.733 Stats_V2[2647:70b] Found Char : /V1
2014-05-01 14:56:03.733 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.733 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.734 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.734 Stats_V2[2647:70b] Found Char : V2
2014-05-01 14:56:03.734 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.734 Stats_V2[2647:70b] Found Char : 155
2014-05-01 14:56:03.734 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.735 Stats_V2[2647:70b] Found Char : /V2
2014-05-01 14:56:03.735 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.735 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.735 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.735 Stats_V2[2647:70b] Found Char : V3
2014-05-01 14:56:03.735 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.736 Stats_V2[2647:70b] Found Char : 3460
2014-05-01 14:56:03.736 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.736 Stats_V2[2647:70b] Found Char : /V3
2014-05-01 14:56:03.736 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.736 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.737 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.737 Stats_V2[2647:70b] Found Char : /Row
2014-05-01 14:56:03.737 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.737 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.737 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.738 Stats_V2[2647:70b] Found Char : Row
2014-05-01 14:56:03.738 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.738 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.738 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.738 Stats_V2[2647:70b] Found Char : Sector
2014-05-01 14:56:03.739 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.739 Stats_V2[2647:70b] Found Char : qwefqef
2014-05-01 14:56:03.739 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.739 Stats_V2[2647:70b] Found Char : /Sector
2014-05-01 14:56:03.739 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.739 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.740 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.740 Stats_V2[2647:70b] Found Char : V1
2014-05-01 14:56:03.740 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.740 Stats_V2[2647:70b] Found Char : 40090
2014-05-01 14:56:03.740 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.740 Stats_V2[2647:70b] Found Char : /V1
2014-05-01 14:56:03.741 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.741 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.741 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.741 Stats_V2[2647:70b] Found Char : V2
2014-05-01 14:56:03.741 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.742 Stats_V2[2647:70b] Found Char : 2816
2014-05-01 14:56:03.742 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.742 Stats_V2[2647:70b] Found Char : /V2
2014-05-01 14:56:03.742 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.742 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.743 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.743 Stats_V2[2647:70b] Found Char : V3
2014-05-01 14:56:03.743 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.743 Stats_V2[2647:70b] Found Char : 42906
2014-05-01 14:56:03.743 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.743 Stats_V2[2647:70b] Found Char : /V3
2014-05-01 14:56:03.744 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.744 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.744 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.744 Stats_V2[2647:70b] Found Char : /Row
2014-05-01 14:56:03.744 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.745 Stats_V2[2647:70b] Found Char :
2014-05-01 14:56:03.745 Stats_V2[2647:70b] Found Char : <
2014-05-01 14:56:03.745 Stats_V2[2647:70b] Found Char : /Report
2014-05-01 14:56:03.745 Stats_V2[2647:70b] Found Char : >
2014-05-01 14:56:03.745 Stats_V2[2647:70b] End Element : GetReportsXMLResult
2014-05-01 14:56:03.746 Stats_V2[2647:70b] End Element : GetReportsXMLResponse
2014-05-01 14:56:03.746 Stats_V2[2647:70b] End Element : soap:Body
2014-05-01 14:56:03.746 Stats_V2[2647:70b] End Element : soap:Envelope
我的问题为什么解析器不考虑(&#34; Report&#34;,&#34; Sector&#34;,&#34; Row&#34;,&#34; V1&#34;)作为节点喜欢&#34; GetReportsXMLResult&#34; ?