How do I still read an RSS with a missing xml header tag?
I am using C#'s xmlTextReader to parse an RSS xml file. It works fine except when there is a missing header tag. How do I get aro开发者_C百科und this issue without injecting the header myself?
You could use XmlTextReader.Settings.ConformanceLevel
property set to ConformanceLevel.Fragment
. But that will relax some other validation checks.
I got around this by implementing Peter Bromberg's custom RSS reader. It is more work compared to using Microsoft's inbuilt reader, however, you can tweak Bromberg's reader to handle errors in the RSS feed with ease.
精彩评论