<?xml version="1.0" encoding="ISO-8859-1"?>
<Note>
<from>
Ahmad
</from>
<to>
Yasir
</to>
<body>
hello yasir.
</Note>
Above is my xml file which misses the ending tag of <body>.
i want a php program that will detect this error and also fix the error and place the ending tag.
can someone help me?
How to fix errors in XML file using php program?
Moderator: General Moderators
Re: How to fix errors in XML file using php program?
You can read about this in some detail here: http://www.devnull.rs/php/blog/parsing- ... -with-php/hmdnawaz wrote: Above is my xml file which misses the ending tag of <body>.
i want a php program that will detect this error and also fix the error and place the ending tag.
can someone help me?
Essentially, an easy way to do it is:
Code: Select all
$doc = new DOMDocument();
$doc->loadXML($invalid_xml);
$valid_xml = $doc->saveXML();