i have a xml like this:
<cont><?php echo nl2br($cont); ?></cont>
the response is:
<cont>
2<br/>
3<br/>
4<br/>
</cont>
in the page the code is:
mainParentElement = document.getElementById('div_cont');
RemoveAllChildElements(mainParentElement);
mainParentElement.innerHTML = "<div class=\'div_cont\'>" + xmlDoc.getElementsByTagName('cont')[0].childNodes[0].nodeValue + "</div>";
in this case the result in the div is only the first line. (2)
if i deleted the nl2br the result is all the lines. (of course with out the <br>)
how can i add the <br>?
thank you!
Read about
CDATA.There are characters that are not allowed as content of XML tags, like
<, because for the parser they mark the beginning of a tag (obviously).So if you want to have such data as content of a tag, you have to escape it somehow. In XML this is done by wrapping the content into
<![CDATA[ ... ]]>, which explicitly tells the parser to not interpret the data contained (treat it as C haracter DATA).Basically you have to do: