读取XML节点属性

            XmlTextReader xmlDoc = new XmlTextReader(strFilename);
            string strYN;
            string strTime;
            while (xmlDoc.Read())
            {
                if (xmlDoc.NodeType == XmlNodeType.Element)
                {
                    if (xmlDoc.Name == "YN")
                    {
                        string strYN = xml.GetAttribute("value");
                    }
                    if (xmlDoc.Name == "Time")
                    {
                        strTime = xmlDoc.GetAttribute("value");
                    }
                   
                }
            }

            if (strYN=="Y")
            {
                DateTime dtNow = DateTime.Now;

                DateTime dtRegist = Convert.ToDateTime(strTime);

                int dt = (dtNow - dtRegist).Days;

                if (dt<60)
                {
                   
                }

            }

 

你可能感兴趣的:(读取XML节点属性)