php - How to parsing a error customized template in PHPDom? or Other solutions? -


everybody have question in phpdom. want made parer in php code, take trouble.

now, have html tmplate (tmpl.html), following:

 <html xmlns="http://www.w3.org/ns" xmlns:oth="http://some.com/ns">     <title>some page</title>     <body>         <oth:items>             <oth:item>             <div>my name :<input type="text" name="name" value="{name}" /></div>             <div>this photo <img src="{photo}"> </div>             </oth:item>         </oth:items>     </body> </html> 

and , php code (test.php), following:

 <?php $informations = array(  //someone information       '12000647300118' => array(           'name' => 'charles'         , 'photo' => './img/x$fwefjjfjf.png'     )     , '12000647300117' => array(           'name' => 'alise'         , 'photo' => './img/cfg%jddlsjf.png'     ) );  $doc = new domdocument; $doc->loadxml(file_get_contents('./tmpl.html', true)); ?> 

but.......... show error

warning: domdocument::loadxml() [domdocument.loadxml]: opening , ending tag mismatch: img line 8 , in entity, line: 8 in c:\apache2.2\htdocs\test.php on line 12

becouse, tag of img not ending tag

error:<img src="{photo}">

correct:<img src="{photo}" / >


i want made parer paring tmpl.html become:

 <html xmlns="http://www.w3.org/ns" xmlns:oth="http://some.com/ns">     <title>some page</title>     <body>         <items>             <item>             <div>my name :<input type="text" name="name" value="charles" /></div>             <div>this photo <img src="./img/x$fwefjjfjf.png"> </div>             </item>             <item>             <div>my name :<input type="text" name="name" value="alise" /></div>             <div>this photo <img src="./img/cfg%jddlsjf.png"> </div>             </item>         </items>     </body> </html> 

who can showing me solution. thanks. ^_^


Comments