{"id":14342,"date":"2016-08-09T16:15:39","date_gmt":"2016-08-09T13:15:39","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=14342"},"modified":"2018-01-09T10:42:03","modified_gmt":"2018-01-09T08:42:03","slug":"php-parser-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/","title":{"rendered":"PHP Parser Example"},"content":{"rendered":"<p>In this example we are going to learn how to parse xml (Extensible Markup Language) with PHP.\u00a0For this example we will use:<\/p>\n<ol>\n<li>A computer with PHP 5.5 installed<\/li>\n<li>notepad++<\/li>\n<\/ol>\n<p>&nbsp;<br \/>\n&nbsp;<br \/>\n&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 \/>\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 \/>\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>parse.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml; highlight:[1]\">&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 <code>&lt;game&gt;<\/code> and ends with a matching <code>&lt;\/game&gt;<\/code> and 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<ol>\n<li>XML is case sensitive so <code>&lt;Title&gt;<\/code> is not the same as<code>&lt;title&gt;<\/code> .<br \/>\nAll XML elements must have closing tags.<\/li>\n<li>XML requires a root element (the <code>&lt;game&gt;<\/code> tag above serves as our root element)<\/li>\n<li>Attributes must be quoted<\/li>\n<li>Special characters (like &amp;, &lt;, and &gt; signs) must be encoded.<\/li>\n<\/ol>\n<h2>1.1 Parsing XML from a string<\/h2>\n<p>To parse XML we are going to be using the SimpleXML parser. SimpleXML is a PHP extension that easily manipulates and get XML data. It turns an XML document into a data structure you can iterate through like a collection of arrays and objects.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>fromstring.php<\/em><\/span><\/p>\n<pre class=\"brush:php; highlight:[22,31,32]\">&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$xml=simplexml_load_string($par);\r\nif ($xml === false) {\r\necho \"Failed loading XML: \";\r\nforeach(libxml_get_errors() as $error) {\r\necho \"&lt;br&gt;\", $error-&gt;message;\r\n}\r\n} \r\nelse{\r\nprint_r($xml);\r\n\r\n}\r\n?&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>In line 22 we store our XML formated string in a variable named <code>$par<\/code>. In line 31 we call the <code> simplexml_load_string($par);<\/code> supplying our XML formatted string as an argument. In line 32 we check if our function returned successfully, if it did we use PHP <code>print_r<\/code> to print out our result. If an error occurred we print out the error.<\/p>\n<h2>1.2 Reading XML from a file<\/h2>\n<p><span style=\"text-decoration: underline;\"><em>fromfile.php<\/em><\/span><\/p>\n<pre class=\"brush:php; highlight:[22]\">&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$xml=simplexml_load_file(\"parse.xml\")or die(\"An Error Occurred\");\r\nprint_r($xml);\r\n?&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>In line 22 we call function <code>simplexml_load_file(\"parse.xml\")<\/code> to parse our XML file supplying the name of the file to parse as an argument.<\/p>\n<h2>1.3 Getting Node Values<\/h2>\n<p><span style=\"text-decoration: underline;\"><em>node.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;&lt;\/game&gt;\";\r\n$xml=simplexml_load_string($par) or die(\"Error Occurred\");\r\necho \"The name of the game is \". $xml-&gt;name.\"&lt;br&gt;&lt;br&gt;\";\r\necho \"Game Description \" . $xml-&gt;description. \"&lt;br&gt;&lt;br&gt;\";\r\necho \"The game version is \".$xml-&gt;version.\"&lt;br&gt;&lt;br&gt;\"\r\n?&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>Lets looks at another example.<br \/>\n<span style=\"text-decoration: underline;\"><em>node1.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;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;&lt;\/game&gt; &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;&lt;\/games&gt;\";\r\n$xml=simplexml_load_string($par) or die(\"Error Occurred\");\r\necho \"The name of the game is \". $xml-&gt;game[1]-&gt;name.\"&lt;br&gt;&lt;br&gt;\";\r\necho \"Game Description \" . $xml-&gt;game[1]-&gt;description. \"&lt;br&gt;&lt;br&gt;\";\r\necho \"The game version is \".$xml-&gt;game[1]-&gt;version.\"&lt;br&gt;&lt;br&gt;\";\r\n\r\necho \"The name of the game is \". $xml-&gt;game[2]-&gt;name.\"&lt;br&gt;&lt;br&gt;\";\r\necho \"Game Description \" . $xml-&gt;game[2]-&gt;description. \"&lt;br&gt;&lt;br&gt;\";\r\necho \"The game version is \".$xml-&gt;game[2]-&gt;version.\"&lt;br&gt;&lt;br&gt;\";\r\n?&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h2>1.4 Getting The Node Value With A Loop<\/h2>\n<p><span style=\"text-decoration: underline;\"><em>node2.php<\/em><\/span><\/p>\n<pre class=\"brush:php; highlight:[22-27]\">&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$xml=simplexml_load_file(\"parse.xml\") or die(\"Error Occurred\");\r\nforeach($xml-&gt;children() as $game) {\r\necho \"The name of the game is \". $game-&gt;name.\"&lt;br&gt;&lt;br&gt;\";\r\necho \"Game Description \" . $game-&gt;description. \"&lt;br&gt;&lt;br&gt;\";\r\necho \"The game version is \".$game-&gt;version.\"&lt;br&gt;&lt;br&gt;\";\r\n}\r\n?&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>In this script we loop through the nodes(line 23 to 27)<\/p>\n<h2>2 Summary<\/h2>\n<p>In this example we have learnt about XML. We also learnt how to parse XML from a file and string in PHP.<\/p>\n<h2>3. Download the source code<\/h2>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <strong><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/08\/phpparserexample.zip\">phpparserexample<\/a><br \/>\n<\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this example we are going to learn how to parse xml (Extensible Markup Language) with PHP.\u00a0For this example we will use: A computer with PHP 5.5 installed notepad++ &nbsp; &nbsp; &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 a syntax for &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":[122],"class_list":["post-14342","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PHP Parser Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"In this example we are going to learn how to parse xml (Extensible Markup Language) with PHP.\u00a0For this example we will use: A computer with PHP 5.5\" \/>\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-parser-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP Parser Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"In this example we are going to learn how to parse xml (Extensible Markup Language) with PHP.\u00a0For this example we will use: A computer with PHP 5.5\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/php\/php-parser-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-08-09T13:15:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-01-09T08:42:03+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-parser-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/\"},\"author\":{\"name\":\"Olayemi Odunayo\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8\"},\"headline\":\"PHP Parser Example\",\"datePublished\":\"2016-08-09T13:15:39+00:00\",\"dateModified\":\"2018-01-09T08:42:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/\"},\"wordCount\":549,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"keywords\":[\"php\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/\",\"name\":\"PHP Parser Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"datePublished\":\"2016-08-09T13:15:39+00:00\",\"dateModified\":\"2018-01-09T08:42:03+00:00\",\"description\":\"In this example we are going to learn how to parse xml (Extensible Markup Language) with PHP.\u00a0For this example we will use: A computer with PHP 5.5\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-parser-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-parser-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 Parser 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 Parser Example - Web Code Geeks - 2026","description":"In this example we are going to learn how to parse xml (Extensible Markup Language) with PHP.\u00a0For this example we will use: A computer with PHP 5.5","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-parser-example\/","og_locale":"en_US","og_type":"article","og_title":"PHP Parser Example - Web Code Geeks - 2026","og_description":"In this example we are going to learn how to parse xml (Extensible Markup Language) with PHP.\u00a0For this example we will use: A computer with PHP 5.5","og_url":"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2016-08-09T13:15:39+00:00","article_modified_time":"2018-01-09T08:42:03+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-parser-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/"},"author":{"name":"Olayemi Odunayo","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8"},"headline":"PHP Parser Example","datePublished":"2016-08-09T13:15:39+00:00","dateModified":"2018-01-09T08:42:03+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/"},"wordCount":549,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","keywords":["php"],"articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/","url":"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/","name":"PHP Parser Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","datePublished":"2016-08-09T13:15:39+00:00","dateModified":"2018-01-09T08:42:03+00:00","description":"In this example we are going to learn how to parse xml (Extensible Markup Language) with PHP.\u00a0For this example we will use: A computer with PHP 5.5","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/php\/php-parser-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/php\/php-parser-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-parser-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 Parser 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\/14342","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=14342"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/14342\/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=14342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=14342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=14342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}