{"id":4632,"date":"2023-06-14T11:21:19","date_gmt":"2023-06-14T10:21:19","guid":{"rendered":"https:\/\/www.utilewebsites.nl\/knowledgebase\/secure-xml-export-using-htmlspecialchars-in-php\/"},"modified":"2023-06-14T11:29:02","modified_gmt":"2023-06-14T10:29:02","slug":"secure-xml-export-using-htmlspecialchars-in-php","status":"publish","type":"wz_knowledgebase","link":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/secure-xml-export-using-htmlspecialchars-in-php\/","title":{"rendered":"Secure XML export using htmlspecialchars() in PHP"},"content":{"rendered":"\n<p>The PHP function <code>htmlspecialchars()<\/code> is important when exporting text to formats such as XML or HTML, where special characters have special meaning. This function replaces special characters with their corresponding HTML entities so that the characters are displayed as plain text and do not disrupt the document structure.<\/p>\n\n\n\n<p>The use of <code>htmlspecialchars()<\/code> is especially important when displaying user input on a Web page to avoid potential security problems such as cross-site scripting (XSS).<\/p>\n\n\n\n<p>For example, if we want to export the text \"This is a &amp; example \" to XML, we need to use <code>htmlspecialchars()<\/code> with the argument <code>ENT_XML1<\/code>. This causes the special character \"&amp;\" to be replaced with \"&amp;amp;\" to ensure valid XML.<\/p>\n\n\n\n<p>Here is a brief example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$input = \"This is a &amp; example\";\n$output = htmlspecialchars($input, ENT_XML1);\necho $output;\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>De uitvoer zal zijn: \"This is a &amp;amp; example<\/code><\/pre>\n\n\n\n<p>Using <code>htmlspecialchars()<\/code> with <code>ENT_XML1<\/code>, special characters are correctly replaced with the appropriate XML entities, keeping your exported text data valid XML.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The PHP function htmlspecialchars() is important when exporting text to formats such as XML or HTML, where special characters have special meaning. This function replaces special characters with their corresponding HTML entities so that the characters are displayed as plain text and do not disrupt the document structure. The use of htmlspecialchars() is especially important when displaying user input on a Web page to avoid potential security problems such as cross-site scripting (XSS). For example, if we want to export the text \"This is a &amp; example \" to XML, we need to use htmlspecialchars() with the argument ENT_XML1. This&nbsp;<a href=\"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/secure-xml-export-using-htmlspecialchars-in-php\/\" class=\"read-more\">Continue Reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"wzkb_category":[40],"wzkb_tag":[],"class_list":["post-4632","wz_knowledgebase","type-wz_knowledgebase","status-publish","hentry","wzkb_category-web-developer-programmeur"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Secure XML export using htmlspecialchars() in PHP - Utilewebsites<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/secure-xml-export-using-htmlspecialchars-in-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Secure XML export using htmlspecialchars() in PHP - Utilewebsites\" \/>\n<meta property=\"og:description\" content=\"The PHP function htmlspecialchars() is important when exporting text to formats such as XML or HTML, where special characters have special meaning. This function replaces special characters with their corresponding HTML entities so that the characters are displayed as plain text and do not disrupt the document structure. The use of htmlspecialchars() is especially important when displaying user input on a Web page to avoid potential security problems such as cross-site scripting (XSS). For example, if we want to export the text &quot;This is a &amp; example &quot; to XML, we need to use htmlspecialchars() with the argument ENT_XML1. This&nbsp;Continue Reading\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/secure-xml-export-using-htmlspecialchars-in-php\/\" \/>\n<meta property=\"og:site_name\" content=\"Utilewebsites\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-14T10:29:02+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/secure-xml-export-using-htmlspecialchars-in-php\\\/\",\"url\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/secure-xml-export-using-htmlspecialchars-in-php\\\/\",\"name\":\"Secure XML export using htmlspecialchars() in PHP - Utilewebsites\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#website\"},\"datePublished\":\"2023-06-14T10:21:19+00:00\",\"dateModified\":\"2023-06-14T10:29:02+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/secure-xml-export-using-htmlspecialchars-in-php\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/secure-xml-export-using-htmlspecialchars-in-php\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/secure-xml-export-using-htmlspecialchars-in-php\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Knowledge Base\",\"item\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Secure XML export using htmlspecialchars() in PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/\",\"name\":\"Utilewebsites\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#organization\",\"name\":\"Utilewebsites\",\"url\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.utilewebsites.nl\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/logo-Utilewebsites-2017.png\",\"contentUrl\":\"https:\\\/\\\/www.utilewebsites.nl\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/logo-Utilewebsites-2017.png\",\"width\":3000,\"height\":593,\"caption\":\"Utilewebsites\"},\"image\":{\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Secure XML export using htmlspecialchars() in PHP - Utilewebsites","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/secure-xml-export-using-htmlspecialchars-in-php\/","og_locale":"en_US","og_type":"article","og_title":"Secure XML export using htmlspecialchars() in PHP - Utilewebsites","og_description":"The PHP function htmlspecialchars() is important when exporting text to formats such as XML or HTML, where special characters have special meaning. This function replaces special characters with their corresponding HTML entities so that the characters are displayed as plain text and do not disrupt the document structure. The use of htmlspecialchars() is especially important when displaying user input on a Web page to avoid potential security problems such as cross-site scripting (XSS). For example, if we want to export the text \"This is a &amp; example \" to XML, we need to use htmlspecialchars() with the argument ENT_XML1. This&nbsp;Continue Reading","og_url":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/secure-xml-export-using-htmlspecialchars-in-php\/","og_site_name":"Utilewebsites","article_modified_time":"2023-06-14T10:29:02+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/secure-xml-export-using-htmlspecialchars-in-php\/","url":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/secure-xml-export-using-htmlspecialchars-in-php\/","name":"Secure XML export using htmlspecialchars() in PHP - Utilewebsites","isPartOf":{"@id":"https:\/\/www.utilewebsites.nl\/en\/#website"},"datePublished":"2023-06-14T10:21:19+00:00","dateModified":"2023-06-14T10:29:02+00:00","breadcrumb":{"@id":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/secure-xml-export-using-htmlspecialchars-in-php\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/secure-xml-export-using-htmlspecialchars-in-php\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/secure-xml-export-using-htmlspecialchars-in-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.utilewebsites.nl\/en\/"},{"@type":"ListItem","position":2,"name":"Knowledge Base","item":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/"},{"@type":"ListItem","position":3,"name":"Secure XML export using htmlspecialchars() in PHP"}]},{"@type":"WebSite","@id":"https:\/\/www.utilewebsites.nl\/en\/#website","url":"https:\/\/www.utilewebsites.nl\/en\/","name":"Utilewebsites","description":"","publisher":{"@id":"https:\/\/www.utilewebsites.nl\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.utilewebsites.nl\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.utilewebsites.nl\/en\/#organization","name":"Utilewebsites","url":"https:\/\/www.utilewebsites.nl\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.utilewebsites.nl\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.utilewebsites.nl\/wp-content\/uploads\/2019\/08\/logo-Utilewebsites-2017.png","contentUrl":"https:\/\/www.utilewebsites.nl\/wp-content\/uploads\/2019\/08\/logo-Utilewebsites-2017.png","width":3000,"height":593,"caption":"Utilewebsites"},"image":{"@id":"https:\/\/www.utilewebsites.nl\/en\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wz_knowledgebase\/4632","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wz_knowledgebase"}],"about":[{"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/types\/wz_knowledgebase"}],"author":[{"embeddable":true,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/comments?post=4632"}],"version-history":[{"count":3,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wz_knowledgebase\/4632\/revisions"}],"predecessor-version":[{"id":4635,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wz_knowledgebase\/4632\/revisions\/4635"}],"wp:attachment":[{"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/media?parent=4632"}],"wp:term":[{"taxonomy":"wzkb_category","embeddable":true,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wzkb_category?post=4632"},{"taxonomy":"wzkb_tag","embeddable":true,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wzkb_tag?post=4632"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}