PHP Parsing xml file
PHP parsing xml file, only for learning reference! The sample code is as follows:
<?phpheader ("content-type:text/html; Charset=utf-8 "), if (!isset ($_get[" _u ")) {echo" <script>javascript:alert (' Do not illegally access! '); Window.history.back ();</script> "; exit ();} $url = $_get["_u"];? ><table width= "100%" height= "Auto" cellpadding= "0" cellspacing= "0" ><tbody><?php//Create Document Object $ doc = new DOMDocument (), $doc-Load ($url), $news = $doc-getElementsByTagName ("item"); $title = ""; $date = ""; $deta Il = ""; $len = ($news, length); $model = null;if ($len > 0) {//Traverse child node for ($i = 0; $i < $len; $i + +) {$model = $news, item ($i); $title = $model-getElementsByTagName ("title"), item (0), NodeValue; $da Te = $model getElementsByTagName ("PubDate"), item (0), nodevalue; $detail = Getelementsbytagnam $model E ("Content"), item (0), nodevalue;? ><tr><th><a href= "javascript:void (0);" ><?php Echo ($title)? ></a><a href= "javascript:void (0);" ></a></th><th> <?php Echo ($date)? ></th></tr><tr style= "Display:none;" ><th colspan= "2" > <?php echo ($detail)? ></th></tr><?php}}else{//no content? ><tr>& lt;th colspan= "2" > <b><font color= "Red" > Temporarily no content display! </font></b></th></tr><?php}?></tbody></table>
As follows: