What is loop in XML DOM through PHP

In this article I am going to explain about loop in XML DOM.
  • 2804

Looping through XML DOM in PHP

XML is a data storage format. An XMl file describes the structure of the data. You can read xml file with loop, for it you can intilize the XML parser , load the XML, and loop through all elements of the  <note> element.

Example of looping through XML

To load XML file ,follow the fallowing steps:

First create an XML file:

<?xml version="1.0" encoding="ISONO"?>





  <body>Don't forget me this weekend!</body>


After it, create a PHP application for reading  an XML file through loop:




$xmlDoc = new DOMDocument();



$x = $xmlDoc->documentElement;

foreach ($x->childNodes AS $item)


  print $item->nodeName . " = " . $item->nodeValue . "<br />";






loopxml dom php.jpg

You may also want to read these related articles :

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.