开发者

SAXParser how to ignore white space in element text

i have SAXParser to parse xml feed, for some element there are whitespace characters embedded like

开发者_StackOverflow <category>Beauty, Spas, & Salons</category>

and the parser only extract 'Beauty' from 'category' instead of 'Beauty, Spas, & Salons', how can i force it to extract the whole string? thanks


The parser is almost certainly giving you the whole string but it is over multiple calls to characters(). characters() will be called any number of times to deliver the contents of an element; it could be one character at a time. You need to keep a String (or StringBuilder...) and add to it each time characters() is called. You don't know you have the whole element content until endElement() is called.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜