PHP 7 Script to Parse XML File Using foreach Loop Full Project For Beginners

  • Post author:
  • Post category:PHP
  • Post comments:0 Comments

 

Welcome folks today in this blog post we will be parsing xml file using foreach loop using php 7. All the full source code of the application is shown below.

 

 

 

Get Started

 

 

 

In order to get started you need to make an index.php file and copy paste the following code

 

 

See also  PHP 7 Script to Validate Date String in Browser Full Project For Beginners

index.php

 

 

<?php
   
   $xml = simplexml_load_file('data.xml');
   $data= $xml->topic;
   foreach ($data as $showname) {
     foreach ($showname->name as $names) {
       echo "$names"."<br>";
       
     }
     
   }
   
   
   ?>

Leave a Reply