]> git.wh0rd.org Git - tt-rss.git/commitdiff
opml: clean empty categories
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 15 Aug 2012 11:55:41 +0000 (15:55 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 15 Aug 2012 11:55:41 +0000 (15:55 +0400)
classes/opml.php

index f7bab4fff1523c2ff91e0d63cfeeb3a5c6117035..011c66eb2eeca240f25f2571e913002b937307d2 100644 (file)
@@ -201,6 +201,16 @@ class Opml extends Protected_Handler {
                $doc->formatOutput = true;\r
                $doc->preserveWhiteSpace = false;\r
                $doc->loadXML($out);\r
+\r
+               $xpath = new DOMXpath($doc);\r
+               $outlines = $xpath->query("//outline[@title]");\r
+\r
+               // cleanup empty categories\r
+               foreach ($outlines as $node) {\r
+                       if ($node->getElementsByTagName('outline')->length == 0)\r
+                               $node->parentNode->removeChild($node);\r
+               }\r
+\r
                $res = $doc->saveXML();\r
 \r
                // saveXML uses a two-space indent.  Change to tabs.\r