开发者

SAXParser how to ignore white space in element text

开发者 https://www.devze.com 2023-03-20 15:59 出处:网络
i have SAXParser to parse xml feed, for some element there are whitespace characters embedded like 开发者_StackOverflow <category>Beauty, Spas, & Salons</category>

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

精彩评论

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