Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to parsing a error customized template in PHPDom? or Other solutions?
    primarykey
    data
    text
    <p>everybody I have a question in PHPDom. I want to made a parer in php code, but I take a trouble.</p> <p>Now, it have a HTML tmplate (tmpl.html), like following:</p> <pre> &lt;html xmlns=&quot;http://www.w3.org/ns&quot; xmlns:oth=&quot;http://some.com/ns&quot;&gt; &lt;title&gt;Some Page&lt;/title&gt; &lt;body&gt; &lt;oth:items&gt; &lt;oth:item&gt; &lt;div&gt;my name is :&lt;input type=&quot;text&quot; name=&quot;name&quot; value=&quot;{name}&quot; /&gt;&lt;/div&gt; &lt;div&gt;this is my photo &lt;img src=&quot;{photo}&quot;&gt;&nbsp;&lt;/div&gt; &lt;/oth:item&gt; &lt;/oth:items&gt; &lt;/body&gt; &lt;/html&gt; </pre> <p>and , a PHP code (test.php), like following:</p> <pre> &lt;?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)); ?&gt; </pre> <p>BUT.......... it show a error</p> <blockquote> <p>Warning: DOMDocument::loadXML() [domdocument.loadxml]: Opening and ending tag mismatch: img line 8 and a in Entity, line: 8 in C:\Apache2.2\htdocs\test.php on line 12</p> </blockquote> <p>becouse, the tag of img is not a ending tag</p> <blockquote> <p><strong>Error:</strong>&lt;img src="{photo}"&gt;</p> <p><strong>Correct:</strong>&lt;img src="{photo}" <strong>/</strong> &gt;</p> </blockquote> <hr> <p>I want made a parer to paring tmpl.html become:</p> <pre> &lt;html xmlns=&quot;http://www.w3.org/ns&quot; xmlns:oth=&quot;http://some.com/ns&quot;&gt; &lt;title&gt;Some Page&lt;/title&gt; &lt;body&gt; &lt;items&gt; &lt;item&gt; &lt;div&gt;my name is :&lt;input type=&quot;text&quot; name=&quot;name&quot; value=&quot;Charles&quot; /&gt;&lt;/div&gt; &lt;div&gt;this is my photo &lt;img src=&quot;./img/X$FWEFjjfjf.png&quot;&gt;&nbsp;&lt;/div&gt; &lt;/item&gt; &lt;item&gt; &lt;div&gt;my name is :&lt;input type=&quot;text&quot; name=&quot;name&quot; value=&quot;Alise&quot; /&gt;&lt;/div&gt; &lt;div&gt;this is my photo &lt;img src=&quot;./img/CFG%Jddlsjf.png&quot;&gt;&nbsp;&lt;/div&gt; &lt;/item&gt; &lt;/items&gt; &lt;/body&gt; &lt;/html&gt; </pre> <p>Who can showing me the solution. thanks. ^_^</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload