NEWS FEED READ XML FILE CODE

<?php<?php $path=”C:\Program Files (x86)\NEWS\XmlCorePlus\\”; $array=array(); $it = new FilesystemIterator($path); foreach ($it as $fileinfo) { $allowed =  array(‘xml’); $filename = $fileinfo->getFilename(); $ext = pathinfo($filename, PATHINFO_EXTENSION); if(in_array($ext,$allowed)) { $booksfile=$fileinfo->getFilename(); } //array_push($array,$arr); //echo $booksfile; die(); //echo $path.””.$booksfile;$doc = new DOMDocument();$doc->load($path.””.$booksfile);//echo “<br>”; print_r($doc); die();$books = $doc->getElementsByTagName(“channel”);
foreach( $books as $book ){$authors = $book->getElementsByTagName(“title”);$author = $authors->item(0)->nodeValue; $publishers = $book->getElementsByTagName(“link”);$publisher = $publishers->item(0)->nodeValue; $titles = $book->getElementsByTagName(“author”);$title = $titles->item(0)->nodeValue;$descriptions = $book->getElementsByTagName(“description”);$description = $descriptions->item(0)->nodeValue;$categorys = $book->getElementsByTagName(“category”);$category = $categorys->item(0)->nodeValue;$sources = $book->getElementsByTagName(“source”);$source = $sources->item(0)->nodeValue;$pubdates = $book->getElementsByTagName(“pubdate”);$pubdate = $pubdates->item(0)->nodeValue;    echo $title.”<br>”.$author.”<br>”.$publisher.”<br>”.$description.”<br>”.$category.”<br>”.$source.”<br>”.$pubdate;
}
}      ?>

Advertisements