Convert & lt to <xml document

I read the XML file and converted to an NSXMLDocument object. But due to the presence of "<" in the string content of the node, it has been converted to "& lt". Therefore, when I write it as an XML document to a file, it has the "& lt" symbol in it.

How can I write the file as a regular XML file, in which "& lt" will be replaced by "<".

Thank you and respect, Lenin

+5
source share
5 answers

When a symbol <appears in the node text, it will be serialized as &lt;if writing your xml to a file.

When you later read this file using the xml parser, the node text will contain the original character <.

CDATA, node. < CDATA. XML-API CDATA . CDATA , .

+4

< xml &lt;.

s/&lt;/</g, xml , .

+1

.

htmlspecialchars

htmlentities()

0

< , XML ( . ). XML...

, , XML-:

  • < , XML- (, , ). , - *-lt-*.
  • & .
  • *-lt-* < .
  • , , XML.

, XML... , XML-.

0

& lt < XML php:

$xmlFile = file_get_contents("example.xml");

$xml= str_replace(['&lt;','&gt;'],['<','>'], $xmlFile);

echo $xml;

I get the feed from the server via XML and then save it in another XML file, I get the result with &lt;and &gt;, therefore, I used this method. This is not the smartest way to store XML, but I'm not a senior professional either.

0
source

All Articles