コード例 #1
0
        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);
        }
コード例 #2
0
        static NSDictionary DictionaryWithContentsOfString(string text, FileUtils.ZipDelegate zip = null)
        {
            if (text == null || text.Length == 0)
            {
                return(null);
            }
            try{
                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);
                if (dict != null)
                {
                    dict.zip = zip;
                }
                return(dict);
            }catch (Exception e) {
                CCDebug.Warning("NSDicitonary:DictionaryWithContentsOfString:Error:{0}", e);
                return(null);
            }
        }
コード例 #3
0
 public string convertToXml()
 {
     return(NSCollectionUtils.ConvertToXml(this));
 }