let channel_of_source source =
let xml = XmlParser.parse t_parser source in
match xml with
| PCData _ -> failwith "Parse error: not an element"
| Element (e, atts, subs) ->
match String.lowercase e with
"rss" ->
(
match subs with
[Element (e, atts, subs)] ->
(
match String.lowercase e with
"channel" -> channel_of_xmls subs
| _ -> failwith "Parse error: not channel"
)
| _ ->
failwith "Parse error: two much things in rss"
)
| "rdf:rdf" ->
(
match subs with
| [] ->
failwith "Parse error: no channel"
| (Element (e, atts, subs)) :: q ->
(
match String.lowercase e with
"channel" -> channel_of_xmls (subs @ q)
| _ -> failwith "Parse error: not channel"
)
| _ ->
failwith "Parse error: not channel"
)
| _ ->
failwith "Parse error: not rss"