PHP XML Reader Coding

FratBro23
Category:
Programming
Price: $5 USD

Question description

What is the alternative way to read an XML file from PHP, below is my coding and what i am required to do:

I'm trying to read information from an XML file using php. When i run the code bellow on my local machine i can view all the information, but when i upload the web pages and xml file to the server the web page freezes and does not display the information.
XML
<?xml version="1.0" encoding="UTF-8"?>

<entry><entryname="naam"type="string">Tove</entry>

<entryname="SNaam"type="string">Jani</entry>

<entryname="Head"type="string">Reminder</entry>

<entryname="Message"type="string">Don't forget me this weekend!</entry></entry>
PHP
<?php

    $xmlPath ='default.xml';
    $objDOM =newDOMDocument('1.0','utf-8');
    $objDOM->load($xmlPath);//make sure path is correct 
    $label = $objDOM->getElementsByTagName("entry");foreach($label as $val){if($val->getAttribute('type')==='string'){
            echo  $val->nodeValue;}

}

?>



I need to get below output:
Tove

Jani
Reminder
Don't forget me this weekend!

Tutor Answer

(Top Tutor) Daniel C.
(997)
School: Boston College
PREMIUM TUTOR
Studypool has helped 1,244,100 students
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1820 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors