File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change 14
14
use Forensic \FeedParser \Exceptions \InvalidURLException ;
15
15
use Forensic \FeedParser \Exceptions \ResourceNotFoundException ;
16
16
use Forensic \FeedParser \Exceptions \FileNotFoundException ;
17
+ use Forensic \FeedParser \Exceptions \MalformedFeedException ;
18
+ use Forensic \FeedParser \Exceptions \FeedTypeNotSupportedException ;
17
19
18
20
/**
19
21
* Class Parser
@@ -49,7 +51,34 @@ public function getDefaultLanguage()
49
51
*/
50
52
private function parse (string $ xml )
51
53
{
52
- return null ;
54
+ $ xml_instance = new XML ($ xml );
55
+ if (!$ xml_instance ->status ())
56
+ throw new MalformedFeedException (implode ("\n" , $ xml_instance ->errors ()));
57
+
58
+ $ doc = $ xml_instance ->document ();
59
+ $ xpath = new XPath ($ doc );
60
+
61
+ $ result = null ;
62
+
63
+ //inspect feed type
64
+ $ feed_name = explode (': ' , $ doc ->documentElement ->tagName )[0 ];
65
+ switch (strtolower ($ feed_name ))
66
+ {
67
+ case 'feed ' :
68
+ $ result = null ;
69
+ break ;
70
+ case 'rss ' :
71
+ $ result = null ;
72
+ break ;
73
+ case 'rdf ' :
74
+ $ result = null ;
75
+ break ;
76
+ default :
77
+ $ message = $ feed_name . ' feed type is currently not support ' ;
78
+ throw new FeedTypeNotSupportedException ($ message );
79
+ break ;
80
+ }
81
+ return $ result ;
53
82
}
54
83
55
84
/**
You can’t perform that action at this time.
0 commit comments