{"id":435,"date":"2015-06-01T07:47:39","date_gmt":"2015-06-01T05:47:39","guid":{"rendered":"http:\/\/floris.briolas.nl\/floris\/?p=435"},"modified":"2015-06-02T10:32:15","modified_gmt":"2015-06-02T08:32:15","slug":"xml-literals-escaping","status":"publish","type":"post","link":"https:\/\/floris.briolas.nl\/floris\/2015\/06\/xml-literals-escaping\/","title":{"rendered":"Xml literals escaping"},"content":{"rendered":"<p>I am somewhat\u00a0bias towards C#, but one can admire the xml literals in vb.net.<\/p>\n<p>This is a language feature where you can just add xml to<\/p>\n<p>Dim someXml As XElement = &lt;foo&gt;bla&lt;bar active=&#8221;false&#8221;\/&gt;&lt;\/foo&gt;<\/p>\n<p>But how do you add characters that have some a meaning in xml, like &#8220;&amp;&#8221; or &#8220;&lt;&#8220;. Turns out you have two options:<\/p>\n<p>Look up how you should escape it (&amp; =&gt; &amp;amp; ) but the editor (vs2013) will show wavy underlines underneath the literal. It will compile do and work as expected.<\/p>\n<p>Embed a literal string<\/p>\n<p>Dim someXml As XElement =\u00a0&lt;foo&gt;Ampersand &lt;%= &#8220;&amp;&#8221; %&gt;&lt;bar active=&#8221;false&#8221;\/&gt;&lt;\/foo&gt;<\/p>\n<p>this uses a method to <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/bb384752.aspx\">embed expressions in xml literals<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am somewhat\u00a0bias towards C#, but one can admire the xml literals in vb.net. This is a language feature where you can just add xml to Dim someXml As XElement = &lt;foo&gt;bla&lt;bar active=&#8221;false&#8221;\/&gt;&lt;\/foo&gt; But how do you add characters that have some a meaning in xml, like &#8220;&amp;&#8221; or &#8220;&lt;&#8220;. Turns out you have two [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[3],"tags":[17],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p61yPs-71","_links":{"self":[{"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/posts\/435"}],"collection":[{"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/comments?post=435"}],"version-history":[{"count":5,"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/posts\/435\/revisions"}],"predecessor-version":[{"id":440,"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/posts\/435\/revisions\/440"}],"wp:attachment":[{"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/media?parent=435"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/categories?post=435"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/floris.briolas.nl\/floris\/wp-json\/wp\/v2\/tags?post=435"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}