<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_66236"> <div class="blockcode"> <div id="code_tlX"><ol> <li>$xml_string="<?xml version='1.0'?></li> <li><moleculedb></li> <li> <molecule name='Benzine'></li> <li> <symbol>ben</symbol></li> <li> <code>A</code></li> <li> </molecule></li> <li> <molecule name='Water'></li> <li> <symbol>h2o</symbol></li> <li> <code>K</code></li> <li> </molecule></li> <li></moleculedb>";</li> <li> </li> <li>//load the xml string using simplexml function</li> <li>$xml = simplexml_load_string($xml_string);</li> <li> </li> <li>//loop through the each node of molecule</li> <li>foreach ($xml->molecule as $record)</li> <li>{</li> <li> //attribute are accessted by</li> <li> echo $record['name'], ' ';</li> <li> //node are accessted by -> operator</li> <li> echo $record->symbol, ' ';</li> <li> echo $record->code, '<br />';</li> <li>}</li> </ol></div> <em onclick="copycode($('code_tlX'));">复制代码</em> </div> <br> </td></tr></table> <div class="ptg mbm mtn"> PHP, XML</div> <div id="comment_66236" class="cm"> </div> <div id="post_rate_div_66236"></div> <br><br>