Frage

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>
War es hilfreich?

Lösung

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.

Andere Tipps

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 '.'.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top