I think a happy accident occurred at work today. Basically I have to use an XML schema defined by someone who didn't really know anything about development. He was a DBA and my company decided all DBAs should become developers so gave them equal titles but as developers instead of DBAs. Dumb, I know. Luckily he has since left the company. So the XML schema is something like such:
The big issue here? He did not know about CDATA tags in XML. So to "fix" the issue what you put into content is always HTML escaped prior to being put into content. So if you have <root><tag>xml > json</tag></root> it would escape the entire thing basically making <root> .... you get the idea. So I was freaking out assuming that what I'd get back would be invalid XML. I assumed it would then unescape the string and I'd get XML with the content <root><tag>xml > json</tag></root>. But I forgot to account for when the entire XML gets escaped the ampersand in the > gets sanitized as well so what it actually puts in is &>. So when it then unescapes it turns the & into an ampersand then gt; (ie: &gt
Thus the unescaping reads the & and replaces with an ampersand but the next thing is just "gt;" without the leading ampersand so it doesn't unescape that it just leaves it. So I'm sure through the process of accident the entire thing actually works. I'd still prefer the stuff to be enclosed in a CDATA tag but I'm actually kind of amused how it works at the moment.
The big issue here? He did not know about CDATA tags in XML. So to "fix" the issue what you put into content is always HTML escaped prior to being put into content. So if you have <root><tag>xml > json</tag></root> it would escape the entire thing basically making <root> .... you get the idea. So I was freaking out assuming that what I'd get back would be invalid XML. I assumed it would then unescape the string and I'd get XML with the content <root><tag>xml > json</tag></root>. But I forgot to account for when the entire XML gets escaped the ampersand in the > gets sanitized as well so what it actually puts in is &>. So when it then unescapes it turns the & into an ampersand then gt; (ie: &gt