开发者

Confusion in DefaultHelper class in android

开发者 https://www.devze.com 2023-02-08 06:37 出处:网络
When are the startElement characters StopElement methods called in the DefaultHel开发者_开发百科per class of in android?

When are the startElement characters StopElement methods called in the DefaultHel开发者_开发百科per class of in android?

The package name of the class is org.xml.sax.helpers.DefaultHandler


<pussy> cat </pussy> 

When the xml parser comes across the tag <pussy> , startElement() is called and when the parser detects </pussy> stopElement() is called.

The function characters() is called with the data "cat"


I figured that even after encountering </pussy> , the method character is called.

The characters() method is most probably called the second time (after stopElement()) because there is a whitespace (e.g. newline) character after </pussy>.

Try putting your test XML all on one line to see if it makes any change.


<element>
  This is character. or may be another elements and it's character.
</element>

startElement(..) will be called when any new xml tag get start like and endElement(..) will be called when an element is ended

0

精彩评论

暂无评论...
验证码 换一张
取 消