show xml parse error in php

Solutions on MaxInterview for show xml parse error in php by the best coders in the world

showing results for - "show xml parse error in php"
Ewenn
11 Apr 2017
1<?php
2libxml_use_internal_errors(true);
3$myXMLData =
4"<?xml version='1.0' encoding='UTF-8'?>
5<document>
6  <user>John Doe</wronguser>
7  <email>john@example.com</wrongemail>
8</document>";
9
10$xml = simplexml_load_string($myXMLData);
11if ($xml === false) {
12    echo "Failed loading XML: ";
13    foreach(libxml_get_errors() as $error) {
14        echo "<br>", $error->message;
15    }
16} else {
17    print_r($xml);
18}
19?>