Last active
February 12, 2019 05:34
-
-
Save zappingseb/e02bed95a46839756df14ac167c8b469 to your computer and use it in GitHub Desktop.
Medium to r-bloggers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Content-Type: text/xml'); | |
$xml = new DOMDocument; | |
$url = "https://medium.com/feed/@zappingseb"; | |
$xml->load($url); | |
$book = $xml->documentElement; | |
// we retrieve the chapter and remove it from the book | |
$channel= $book->getElementsByTagName('channel')->item(0); | |
$items = $channel->getElementsByTagName('item'); | |
$domArray = array(); //set up an array to catch all our nodes | |
foreach ($items as $i){ | |
//echo $i->nodeValue; | |
//$title = $i->getElementsByTagName('title')->item(0); | |
//echo $title->nodeValue; | |
//echo "xx<br/>"; | |
$categories = $i->getElementsByTagName('category'); | |
$found = false; | |
foreach($categories as $category){ | |
if($category->nodeValue == "r"){ | |
$found = true; | |
break; | |
} | |
} | |
if(!$found){ | |
$domArray[] = $i; | |
} | |
} | |
foreach($domArray as $i){ | |
$channel->removeChild($i); | |
} | |
echo $xml->saveXML(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment