public static NSDictionary DictionaryWithContentsOfString(string text)
{
if (text == null || text.Length == 0)
{
return(null);
}
text = System.Text.RegularExpressions.Regex.Replace(text, "<.*\\.dtd\">", string.Empty);
XmlReaderSettings settings = new XmlReaderSettings();
settings.ProhibitDtd = false;
settings.ValidationType = ValidationType.None;
XmlDocument xmlDoc = new XmlDocument();
using (StringReader sr = new StringReader(text))
using (XmlReader reader = XmlReader.Create(sr, settings))
{
xmlDoc.Load(reader);
}
// XmlDocument xmlDoc = new XmlDocument();
// xmlDoc.LoadXml (text);
XmlNode rootNode = xmlDoc.DocumentElement.ChildNodes[0];
if (rootNode.Name != "dict")
{
return(null);
}
NSDictionary dict = NSCollectionUtils.ParseDictionary(rootNode);
return(dict);
}