{"id":15362,"date":"2016-12-08T16:15:53","date_gmt":"2016-12-08T14:15:53","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=15362"},"modified":"2018-01-09T10:02:59","modified_gmt":"2018-01-09T08:02:59","slug":"php-xmlencoder-xmldecoder-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/","title":{"rendered":"PHP Xmlencoder &#038; Xmldecoder Example"},"content":{"rendered":"<p>In this example we are going to learn how to encode and decode XML (Extensible Markup Language) with PHP. For this example we will use:<\/p>\n<ul>\n<li>A computer with PHP &gt;= 5.5 installed<\/li>\n<li>notepad++<\/li>\n<\/ul>\n<p>&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n[ulp id=&#8217;8njY7i2QRy6sg8pg&#8217;]<\/p>\n<h2>1. What Is XML<\/h2>\n<p>XML (Extensible Markup Language) is a markup language like html. It is a syntax for creating data representation languages. XML was designed to store and transport data. It was also designed to be human and machine readable.<br \/>\n&nbsp;<br \/>\nXML can be divided into two levels. On the first level XML defines a strict but simple syntax. When this syntax is followed, the document is a well formed XML document. On the second level, XML provides a way of placing further restrictions on what can appear in a document. This is done by associating a DTD (Document Type Definition) with an XML document. A DTD is simply a list of things allowed to appear in the XML document.<br \/>\n&nbsp;<br \/>\nIf you are familiar with HTML, then you already have a basic idea of XML. An HTML document is not an XML document since it does not follow all the strict XML syntax rules.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>index.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" ?&gt;\r\n&lt;games&gt;\r\n&lt;game&gt;\r\n&lt;name&gt; Shadow Clan  &lt;\/name&gt;\r\n&lt;version&gt;1&lt;\/version&gt;\r\n&lt;multiplayer&gt;true&lt;\/multiplayer&gt;\r\n&lt;size w=\"300\" h=\"300\"\/&gt;\r\n&lt;description&gt; The Shadow Clan is a group of elite fighters. There mission is simple protect the world from Dark shadow clan &lt;\/description&gt;\r\n&lt;stage&gt;2&lt;\/stage&gt;\r\n&lt;\/game&gt;\r\n\r\n&lt;game&gt;\r\n&lt;name&gt; Zombie Escape  &lt;\/name&gt;\r\n&lt;version&gt;3.2&lt;\/version&gt;\r\n&lt;multiplayer&gt; false &lt;\/multiplayer&gt;\r\n&lt;size w=\"800\" h=\"300\"\/&gt;\r\n&lt;description&gt; Lagos as been invaded by zombies, lead jane out of the danger zone &lt;\/description&gt;\r\n&lt;stage&gt;2&lt;\/stage&gt;\r\n&lt;\/game&gt;\r\n&lt;game&gt;\r\n&lt;name&gt;Zombie Escape 3 &lt;\/name&gt;\r\n&lt;version&gt;1.0.2&lt;\/version&gt;\r\n&lt;multiplayer&gt;false&lt;\/multiplayer&gt;\r\n&lt;size w=\"800\" h=\"300\"\/&gt;\r\n&lt;description&gt; Lagos as been invaded by zombies, lead jane out of the danger zone &lt;\/description&gt;\r\n&lt;stage&gt; 2 &lt;\/stage&gt;\r\n&lt;\/game&gt;\r\n&lt;\/games&gt;\r\n<\/pre>\n<p>This is a simple XML file that stores data about the games on a server.\u00a0The first line identifies this document as an XML file. On this line we can also specify the character encoding used. The document is made up of elements, attributes and textual content. An element starts with a tag, such as\u00a0<code>&lt;game&gt;<\/code>\u00a0and ends with a matching <code>&lt;game&gt;<\/code>;\u00a0and the content is between the tags, which can consist of text and nested elements.<br \/>\nUnlike HTML the author of an XML document gets to choose the tags names and attribute names.\u00a0Below are some rules for creating XML documents<\/p>\n<ul>\n<li>XML is case sensitive so <code>\u00a0&lt;Title&gt;\u00a0<\/code>is not the same as &lt;title&gt;. All XML elements must have closing tags.<\/li>\n<li>XML requires a root element (the <code> &lt;game&gt;\u00a0<\/code>tag above serves as our root element)<\/li>\n<li>Attributes must be quoted<\/li>\n<li>Special characters (like &amp;,\u00a0&lt; , and &gt; signs) must be encoded.<\/li>\n<\/ul>\n<h3>1.1 Decoding XML<\/h3>\n<p>In the script below we convert an XML string into PHP data type, specifically an array.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>index.php<\/em><\/span><\/p>\n<pre class=\"brush:php\">&lt;!DOCTYPE html&gt; \r\n&lt;html lang=en&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\",\"verdana\",\"calibri\", \"san serif\";\r\n\toverflow:hidden;\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\n\t \r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t&lt;title&gt;Php Parser Example&lt;\/title&gt;\r\n\t&lt;\/head&gt;\r\n\t&lt;body&gt;\r\n&lt;?php\r\n$par=\"&lt;?xml version='1.0' ?&gt;\r\n&lt;game&gt;\r\n&lt;name&gt;Shadow Clan&lt;\/name&gt;\r\n&lt;version&gt;1&lt;\/version&gt;\r\n&lt;multiplayer&gt;true&lt;\/multiplayer&gt;\r\n&lt;size w='300' h='300'\/&gt;\r\n&lt;description&gt;The Shadow Clan is a group of elite fighters. There mission is simple protect the world from Dark shadow clan &lt;\/description&gt;\r\n&lt;stage&gt;2&lt;\/stage&gt;\r\n&lt;\/game&gt;\";\r\n$p=xml_parser_create();\r\nxml_parse_into_struct($p,$par,$vals,$index);\r\necho \"&lt;p&gt;The index for the array&lt;\/p&gt;\";\r\nprint_r($vals);\r\necho \"&lt;p&gt;The values of the xml data&lt;\/p&gt; \";\r\nprint_r($vals);\r\n\/*the calls above returns\r\n\r\nThe index for the array\r\n\r\nArray ( [0] =&gt; Array ( [tag] =&gt; GAME [type] =&gt; open [level] =&gt; 1 [value] =&gt; ) [1] =&gt; Array ( [tag] =&gt; NAME [type] =&gt; complete [level] =&gt; 2 [value] =&gt; Shadow Clan ) [2] =&gt; Array ( [tag] =&gt; GAME [value] =&gt; [type] =&gt; cdata [level] =&gt; 1 ) [3] =&gt; Array ( [tag] =&gt; VERSION [type] =&gt; complete [level] =&gt; 2 [value] =&gt; 1 ) [4] =&gt; Array ( [tag] =&gt; GAME [value] =&gt; [type] =&gt; cdata [level] =&gt; 1 ) [5] =&gt; Array ( [tag] =&gt; MULTIPLAYER [type] =&gt; complete [level] =&gt; 2 [value] =&gt; true ) [6] =&gt; Array ( [tag] =&gt; GAME [value] =&gt; [type] =&gt; cdata [level] =&gt; 1 ) [7] =&gt; Array ( [tag] =&gt; SIZE [type] =&gt; complete [level] =&gt; 2 [attributes] =&gt; Array ( [W] =&gt; 300 [H] =&gt; 300 ) ) [8] =&gt; Array ( [tag] =&gt; GAME [value] =&gt; [type] =&gt; cdata [level] =&gt; 1 ) [9] =&gt; Array ( [tag] =&gt; DESCRIPTION [type] =&gt; complete [level] =&gt; 2 [value] =&gt; The Shadow Clan is a group of elite fighters. There mission is simple protect the world from Dark shadow clan ) [10] =&gt; Array ( [tag] =&gt; GAME [value] =&gt; [type] =&gt; cdata [level] =&gt; 1 ) [11] =&gt; Array ( [tag] =&gt; STAGE [type] =&gt; complete [level] =&gt; 2 [value] =&gt; 2 ) [12] =&gt; Array ( [tag] =&gt; GAME [value] =&gt; [type] =&gt; cdata [level] =&gt; 1 ) [13] =&gt; Array ( [tag] =&gt; GAME [type] =&gt; close [level] =&gt; 1 ) )\r\nThe values of the xml data\r\n\r\nArray ( [0] =&gt; Array ( [tag] =&gt; GAME [type] =&gt; open [level] =&gt; 1 [value] =&gt; ) [1] =&gt; Array ( [tag] =&gt; NAME [type] =&gt; complete [level] =&gt; 2 [value] =&gt; Shadow Clan ) [2] =&gt; Array ( [tag] =&gt; GAME [value] =&gt; [type] =&gt; cdata [level] =&gt; 1 ) [3] =&gt; Array ( [tag] =&gt; VERSION [type] =&gt; complete [level] =&gt; 2 [value] =&gt; 1 ) [4] =&gt; Array ( [tag] =&gt; GAME [value] =&gt; [type] =&gt; cdata [level] =&gt; 1 ) [5] =&gt; Array ( [tag] =&gt; MULTIPLAYER [type] =&gt; complete [level] =&gt; 2 [value] =&gt; true ) [6] =&gt; Array ( [tag] =&gt; GAME [value] =&gt; [type] =&gt; cdata [level] =&gt; 1 ) [7] =&gt; Array ( [tag] =&gt; SIZE [type] =&gt; complete [level] =&gt; 2 [attributes] =&gt; Array ( [W] =&gt; 300 [H] =&gt; 300 ) ) [8] =&gt; Array ( [tag] =&gt; GAME [value] =&gt; [type] =&gt; cdata [level] =&gt; 1 ) [9] =&gt; Array ( [tag] =&gt; DESCRIPTION [type] =&gt; complete [level] =&gt; 2 [value] =&gt; The Shadow Clan is a group of elite fighters. There mission is simple protect the world from Dark shadow clan ) [10] =&gt; Array ( [tag] =&gt; GAME [value] =&gt; [type] =&gt; cdata [level] =&gt; 1 ) [11] =&gt; Array ( [tag] =&gt; STAGE [type] =&gt; complete [level] =&gt; 2 [value] =&gt; 2 ) [12] =&gt; Array ( [tag] =&gt; GAME [value] =&gt; [type] =&gt; cdata [level] =&gt; 1 ) [13] =&gt; Array ( [tag] =&gt; GAME [type] =&gt; close [level] =&gt; 1 ) )\r\n*\/\r\n?&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>In this example we converted an XML formatted string into a PHP array.<br \/>\nWe use the <code>xml_parse_into_struct()\u00a0<\/code> function which takes four parameters. Those\u00a0are:<\/p>\n<ol>\n<li>Parser: it is required. It specifies the XML parser to be used.<\/li>\n<li>xml: it is required. It specifies the XML data to be parsed.<\/li>\n<li>value: It is Required. It specifies the target array for the XML data.<\/li>\n<li>index: This parameter is optional. It specifies the target array for index data.<\/li>\n<\/ol>\n<p>The <code>xml_parse_into_struct()<\/code> function will return 1 if the operation succeeds and 0 for failure. The returned 1 or 0 is not the same as TRUE and FALSE.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>index2.php<\/em><\/span><\/p>\n<pre class=\"brush:php\">&lt;!DOCTYPE html&gt; \r\n&lt;html lang=en&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\",\"verdana\",\"calibri\", \"san serif\";\r\n\toverflow:hidden;\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\n\t \r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t&lt;title&gt;Php Parser Example&lt;\/title&gt;\r\n\t&lt;\/head&gt;\r\n\t&lt;body&gt;\r\n&lt;?php\r\n$par = file_get_contents(\"index.xml\");\/\/ read the contents of a file and store it as a string\r\n$p=xml_parser_create();\r\nxml_parse_into_struct($p,$par,$vals);\r\necho \"&lt;p&gt;The values of the xml data&lt;\/p&gt; \";\r\nprint_r($vals);\r\n?&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>In the script above we read the XML data from a file and store it in a string, Then we use the <code>xml_parse_into_struct()<\/code> to process it.<\/p>\n<h3>1.2 Encoding PHP String into an XML File<\/h3>\n<p><span style=\"text-decoration: underline;\"><em>index4.php<\/em><\/span><\/p>\n<pre class=\"brush:php\">&lt;!DOCTYPE html&gt; \r\n&lt;html lang=en&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\",\"verdana\",\"calibri\", \"san serif\";\r\n\toverflow:hidden;\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\n\t \r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t&lt;title&gt;Php Parser Example&lt;\/title&gt;\r\n\t&lt;\/head&gt;\r\n\t&lt;body&gt;\r\n&lt;?php\r\n$par=&lt;&lt;&lt;XML\r\n&lt;game&gt;\r\n&lt;name&gt;Shadow Clan&lt;\/name&gt;\r\n&lt;version&gt;1&lt;\/version&gt;\r\n&lt;multiplayer&gt;true&lt;\/multiplayer&gt;\r\n&lt;size w='300' h='300'\/&gt;\r\n&lt;description&gt;The Shadow Clan is a group of elite fighters. There mission is simple protect the world from Dark shadow clan &lt;\/description&gt;\r\n&lt;stage&gt;2&lt;\/stage&gt;\r\n&lt;\/game&gt;\r\nXML;\r\n$p= new SimpleXMLElement($par);\r\n$v=$p-&gt;asXML(\"index2.xml\");\r\necho \"&lt;h1&gt; Conversion Of String To XML File Done &lt;\/h1&gt;\";\r\n\r\n?&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>In the script above we successfully converted an XML string into an XML file. We used PHP <code>SimpleXMLElement<\/code> object. The asXML() function returns a well-formed XML string (XML version 1.0) from a SimpleXML object.<br \/>\nWe specify an optional parameter to the function ( this represents a file to save our newly formed XML) . If this parameter is specified it writes the data to the file, instead of returning the string.<\/p>\n<h2>2 Summary<\/h2>\n<p>In this tutorial we learnt about XML. We learnt how to convert an XML file into a PHP array, we also examined\u00a0how to save a XML string into a properly formatted XML file.<\/p>\n<h2>3. Download the source code<\/h2>\n<div class=\"download\">\n<p><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here:\u00a0<strong><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/12\/phpxmlencoderanddecoder.zip\">phpxmlencoderanddecoder<\/a><\/strong><\/p>\n<p>&nbsp;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this example we are going to learn how to encode and decode XML (Extensible Markup Language) with PHP. For this example we will use: A computer with PHP &gt;= 5.5 installed notepad++ &nbsp; &nbsp; &nbsp; &nbsp; [ulp id=&#8217;8njY7i2QRy6sg8pg&#8217;] 1. What Is XML XML (Extensible Markup Language) is a markup language like html. It is &hellip;<\/p>\n","protected":false},"author":164,"featured_media":930,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[408,409],"class_list":["post-15362","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-xml-decoder","tag-xml-encoder"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PHP Xmlencoder &amp; Xmldecoder Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"In this example we are going to learn how to encode and decode XML (Extensible Markup Language) with PHP. For this example we will use: A computer with\" \/>\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.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP Xmlencoder &amp; Xmldecoder Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"In this example we are going to learn how to encode and decode XML (Extensible Markup Language) with PHP. For this example we will use: A computer with\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-12-08T14:15:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-01-09T08:02:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Olayemi Odunayo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Olayemi Odunayo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/\"},\"author\":{\"name\":\"Olayemi Odunayo\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8\"},\"headline\":\"PHP Xmlencoder &#038; Xmldecoder Example\",\"datePublished\":\"2016-12-08T14:15:53+00:00\",\"dateModified\":\"2018-01-09T08:02:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/\"},\"wordCount\":623,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"keywords\":[\"Xml decoder\",\"Xml encoder\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/\",\"name\":\"PHP Xmlencoder & Xmldecoder Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"datePublished\":\"2016-12-08T14:15:53+00:00\",\"dateModified\":\"2018-01-09T08:02:59+00:00\",\"description\":\"In this example we are going to learn how to encode and decode XML (Extensible Markup Language) with PHP. For this example we will use: A computer with\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/php\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PHP Xmlencoder &#038; Xmldecoder Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8\",\"name\":\"Olayemi Odunayo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g\",\"caption\":\"Olayemi Odunayo\"},\"description\":\"I am a programmer and web developer, who has experience in developing websites and writing desktop and mobile applications. I have worked with both schematic and schemaless databases. I am also familiar with third party API and working with cloud servers. I do programming on the client side with Java, JavaScript, html, Ajax and CSS while I use PHP for server side programming.\",\"sameAs\":[\"https:\/\/www.webcodegeeks.com\/\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/olayemi-odunayo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP Xmlencoder & Xmldecoder Example - Web Code Geeks - 2026","description":"In this example we are going to learn how to encode and decode XML (Extensible Markup Language) with PHP. For this example we will use: A computer with","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.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/","og_locale":"en_US","og_type":"article","og_title":"PHP Xmlencoder & Xmldecoder Example - Web Code Geeks - 2026","og_description":"In this example we are going to learn how to encode and decode XML (Extensible Markup Language) with PHP. For this example we will use: A computer with","og_url":"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2016-12-08T14:15:53+00:00","article_modified_time":"2018-01-09T08:02:59+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","type":"image\/jpeg"}],"author":"Olayemi Odunayo","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Olayemi Odunayo","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/"},"author":{"name":"Olayemi Odunayo","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8"},"headline":"PHP Xmlencoder &#038; Xmldecoder Example","datePublished":"2016-12-08T14:15:53+00:00","dateModified":"2018-01-09T08:02:59+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/"},"wordCount":623,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","keywords":["Xml decoder","Xml encoder"],"articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/","url":"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/","name":"PHP Xmlencoder & Xmldecoder Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","datePublished":"2016-12-08T14:15:53+00:00","dateModified":"2018-01-09T08:02:59+00:00","description":"In this example we are going to learn how to encode and decode XML (Extensible Markup Language) with PHP. For this example we will use: A computer with","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/php\/php-xmlencoder-xmldecoder-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"PHP","item":"https:\/\/www.webcodegeeks.com\/category\/php\/"},{"@type":"ListItem","position":3,"name":"PHP Xmlencoder &#038; Xmldecoder Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8","name":"Olayemi Odunayo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g","caption":"Olayemi Odunayo"},"description":"I am a programmer and web developer, who has experience in developing websites and writing desktop and mobile applications. I have worked with both schematic and schemaless databases. I am also familiar with third party API and working with cloud servers. I do programming on the client side with Java, JavaScript, html, Ajax and CSS while I use PHP for server side programming.","sameAs":["https:\/\/www.webcodegeeks.com\/"],"url":"https:\/\/www.webcodegeeks.com\/author\/olayemi-odunayo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/15362","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/164"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=15362"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/15362\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/930"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=15362"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=15362"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=15362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}