{"id":94,"date":"2009-03-27T12:17:11","date_gmt":"2009-03-27T10:17:11","guid":{"rendered":"http:\/\/dev.flauschig.ch\/wordpress\/?p=94"},"modified":"2009-05-16T09:34:30","modified_gmt":"2009-05-16T07:34:30","slug":"excape-invalid-xml-chars","status":"publish","type":"post","link":"http:\/\/dev.flauschig.ch\/wordpress\/?p=94","title":{"rendered":"Escape invalid XML Chars"},"content":{"rendered":"<p>When working with XML, you sometimes want to save some Text into the XML.<br \/>\nThat can lead to problems when you use special Chars which then confuses the XML Parser.<\/p>\n<p>To fix that you could just use multiple Replaces over your String or just use the .Net Function:<br \/>\n<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.security.securityelement.escape.aspx\">System.Security.SecurityElement.Escape<\/a><\/p>\n<p>Example:<\/p>\n<pre class=\"brush: csharp; gutter: false; title: ; toolbar: false; wrap-lines: false; notranslate\" title=\"\">\r\nstring myText = &quot;Hello &amp; World! &lt;3&quot;;\r\nstring myTextXMLSafe = System.Security.SecurityElement.Escape(myText);\r\n\/\/ myTextXMLSafe is now &quot;Hello &amp;amp; World! &amp;lt;3&quot;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>When working with XML, you sometimes want to save some Text into the XML. That can lead to problems when you use special Chars which then confuses the XML Parser. To fix that you could just use multiple Replaces over your String or just use the .Net Function: System.Security.SecurityElement.Escape Example: string myText = &quot;Hello &amp; &hellip; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[4,3],"tags":[23,22],"class_list":{"0":"entry","1":"post","2":"publish","3":"author-roemer","4":"post-94","6":"format-standard","7":"category-csharp","8":"category-programming","9":"post_tag-escape","10":"post_tag-xml"},"acf":[],"views":1827,"_links":{"self":[{"href":"http:\/\/dev.flauschig.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/94"}],"collection":[{"href":"http:\/\/dev.flauschig.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/dev.flauschig.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/dev.flauschig.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/dev.flauschig.ch\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=94"}],"version-history":[{"count":0,"href":"http:\/\/dev.flauschig.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/94\/revisions"}],"wp:attachment":[{"href":"http:\/\/dev.flauschig.ch\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=94"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/dev.flauschig.ch\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=94"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/dev.flauschig.ch\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=94"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}