How do I force using of entities encoding in text nodes in XML::LibXML?

I have on toString() output

<test>&lt;text&gt;&amp;"&lt;/text&gt;</test>

and I need

<test>&lt;text&gt;&amp;&quot;&lt;/text&gt;</test>
有帮助吗?

解决方案

You need to use XML::Entities to encode the string.

In this case you will have to decode the string first, otherwise you will end up with the entities that are already present being doubly-encoded.

其他提示

I don't know why you want that because those two XML snippets are 100% equivalent.

libxml doesn't needlessly use entities for '"' anymore than it does for 't' and '.'.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top