October 14th, 2012, 11:00 AM
[RESOLVED] php DOMDocument load / loadXML when attributes contain end of line characters
I try to load the following XML node into a DOMDocument:
It is a big sorrow that DOMDocument::load() and DOMDocument::loadXML() of both replaces \n to five spaces (using php 5). Looking into the relevant RFC, \n is a perfectly valid character for XML attributes. Qt C++ and java handles it properly as well.
I see that there are options on load and loadXML to change certain behaviors, just I could not find out which one to use for this purpose.
So, how is it possible to force keeping end of line characters (replacing to PHP_EOL does not work either so DOMDocument is the nasty one, the incoming strings are alright). I have some code parsers where code is in the attribute so replacing/escaping is not really an option (of course, I could put there base64 and then decode at use, but that is a very high overhead). Must keep the EOLs.
October 14th, 2012, 11:09 AM
Re: php DOMDocument load / loadXML when attributes contain end of line characters
I looked for this for a bit of time and just found after asking the question:
$Data = str_replace("\n", "xx", $Data);
xx = <amp heshmark one zero semicolon>
in case if others stumble into the same issue
Click Here to Expand Forum to Full Width