开发者

Is there a perl module that will replace HTML/XML character codes with actual characters?

I have a string with XML character codes in it (e.g. &, <, etc.). I was wondering if there is a module that I can use to automatically replace these character codes with the actual characters.

I know that I开发者_运维百科 can write a simple search/replace regex, but then I'd have to make sure I'm not missing any character codes; it seems like the type of thing that would be handled by some existing module.

Thanks!


Hum... Your HTML or XML parser should be doing that for you.

For HTML, you can use HTML::Entities.

For XML, the entity definitions are based on the schema and on the document itself, so it really has to be part of the XML parsing process. The only named entities XML itself knows about are &, <, >, ' and ", but an XML document can use any from an inifinite range of possible entities.


Sounds like you're looking for HTML::Entities from HTML::Parser.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜