Exemplo n.º 1
0
        public static void ParseXML(string filename)
        {
            XDocument  doc  = XDocument.Load(filename);
            XElement   root = doc.Root;
            XNamespace ns   = root.GetDefaultNamespace();

            foreach (XElement response in doc.Descendants(ns + "response"))
            {
                string href = (string)response.Element(ns + "href");
                foreach (XElement propstat in response.Descendants(ns + "propstat"))
                {
                    PropStat newPropStat = new PropStat();
                    propStats.Add(newPropStat);
                    newPropStat.href = href;
                    XElement dsref = propstat.Descendants(ns + "dsref").FirstOrDefault();
                    if (dsref != null)
                    {
                        newPropStat.handle = (string)dsref.Attribute("handle");
                    }
                    newPropStat.firstname = (string)propstat.Descendants(ns + "firstname").FirstOrDefault();
                    newPropStat.lastname  = (string)propstat.Descendants(ns + "lastname").FirstOrDefault();
                    newPropStat.username  = (string)propstat.Descendants(ns + "username").FirstOrDefault();
                    newPropStat.email     = (string)propstat.Descendants(ns + "email").FirstOrDefault();
                    newPropStat.isactive  = (string)propstat.Descendants(ns + "isactive").FirstOrDefault() == "0" ? false : true;
                    newPropStat.domain    = (string)propstat.Descendants(ns + "domain").FirstOrDefault();
                    newPropStat.status    = (string)propstat.Descendants(ns + "status").FirstOrDefault();
                }
            }
        }
Exemplo n.º 2
0
 static void Main(string[] args)
 {
     PropStat.ParseXML(XML_FILENAME);
     PropStat.CreateCSV(CSV_FILENAME);
 }