php解析xml
$con = file_get_contents("http://v.guozitv.com/api/androidxml.php?"); $data = simplexml_load_string($con); print_r($data); echo $data->details; exit;
$doc = new DOMDocument(); $doc->load( $xgweb ); $books = $doc->getElementsByTagName( "item" ); foreach( $books as $book ) { $authors = $book->getElementsByTagName( "author" ); $author = $authors->item(0)->nodeValue; $pubDate = $book->getElementsByTagName( "pubDate" ); $pubDate = $pubDate->item(0)->nodeValue; $titles = $book->getElementsByTagName( "title" ); $title = $titles->item(0)->nodeValue; $descriptions = $book->getElementsByTagName( "description" ); $description = $descriptions->item(0)->nodeValue."..."; $links = $book->getElementsByTagName( "link" ); $link = $links->item(0)->nodeValue; echo "$title - $author - $pubDate - $description - $link ". '<br/>'. '<br/>'. '<br/>'. '<br/>'; }