Pregunta

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>
¿Fue útil?

Solución

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.

Otros consejos

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top