I am trying to parse a .tetml extension file. For this i am using NSXMLParserDelegate
methods.
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)e开发者_如何学PythonlementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
the didEndElement
give me an exact result whereas namespaceURI
and qName
give nil. I am not understanding the exact reason. My file contains:
<Word><Text>ËÒ</Text><Box llx="198.00" lly="408.48" urx="244.90" ury="436.56"><Glyph font="F1" size="40.08" x="198.00" y="408.48" width="26.16">Ë</Glyph><Glyph font="F1" size="28.08" x="224.16" y="408.48" width="20.74">Ò</Glyph></Box></Word>
Can anyone give me the reason why this is happening, and can anyone tell me how to get tag value? Thank you in advance.
Well, I don't see any namespaces in your xml file. If you made sure you had this set on your NSXMLParser instance:
- (void)setShouldProcessNamespaces:YES
... and your xml file looked like this:
<n:Word xmlns:n="http://www.n.com/" xmlns:m="http://www.m.com">
<n:Text>ËÒ</n:Text>
<m:Box llx="198.00" lly="408.48" urx="244.90" ury="436.56">
<m:Glyph font="F1" size="40.08" x="198.00" y="408.48" width="26.16">Ë</m:Glyph>
<m:Glyph font="F1" size="28.08" x="224.16" y="408.48" width="20.74">Ò</m:Glyph>
</m:Box>
</n:Word>
You'd see your -[MyParserDelegate parser:didEndElement:namespaceURI:qualifiedName:] type delegate methods called with
elementName = Text
namespaceURI = http://www.n.com/
qualifiedName = n:Text
Hope this helps.
精彩评论