开发者

DocumentBuilder.parse() / Parsing Entities

开发者 https://www.devze.com 2022-12-28 19:39 出处:网络
I\'m new to parsing XML and am having an issue with entities. (Am doing this on Android, if it mak开发者_JS百科es a difference).

I'm new to parsing XML and am having an issue with entities. (Am doing this on Android, if it mak开发者_JS百科es a difference).

Is there a way to have it turn an entity into the character it represents? I have this in the child of an element: "isn't" (minus quotes). I would prefer it parse it and the end result be a single text node. However, right now this is turned in to TEXT, ENTITY, TEXT.

Is there a way to automatically have it parse the entity into text, or a manual way to do it?


You can't automatically do that, since this is the expected behaviour. It's up to the interpreter what to do with the entities. The average webbrowser for example will interpret and display them flawlessly.

If you're allowed to join a 3rd party library, then I'd suggest to use the Apache Commons Lang StringEscapeUtils#unescapeXml() for this.

0

精彩评论

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