티스토리 뷰

카테고리 없음

C#] XML 읽기

James Wetzel 2014. 10. 13. 09:43
728x90
반응형

XmlDocument doc = new XmlDocument();

            doc.Load("http://localhost:60052/Scripts/test.xml");


            XmlNode StudentListNode = doc.SelectSingleNode("/smses");

            //XmlNodeList StudentNodeList = StudentListNode.SelectNodes("sms");

            

            XmlNodeList StudentNodeList = StudentListNode.SelectNodes("mms");

            XmlNode StudentListNode2 = null;

            XmlNodeList StudentNodeList2 = null;

            string text = string.Empty;

            string type = string.Empty;

            

            IList<MobileSmsEntity> list = new List<MobileSmsEntity>();

                        

            foreach (XmlNode node in StudentNodeList)

            {

                StudentListNode2 = node.SelectSingleNode("parts");

                StudentNodeList2 = StudentListNode2.SelectNodes("part");


                foreach (XmlNode node2 in StudentNodeList2)

                {

                    text = node2.Attributes.GetNamedItem("text").Value;                    

                }


                

                list.Add(new MobileSmsEntity()

                {

                    //in_descr = "sms"

                    //, in_no = node.Attributes.GetNamedItem("address").Value

                    //, in_date = node.Attributes.GetNamedItem("date").Value                     

                    //, in_memo = node.Attributes.GetNamedItem("body").Value 

                    //, in_name = node.Attributes.GetNamedItem("contact_name").Value 

                    //, in_type = node.Attributes.GetNamedItem("type").Value                     

                    //, in_readable_date = node.Attributes.GetNamedItem("readable_date").Value

                    

                    in_descr = "mms"

                    , in_no = node.Attributes.GetNamedItem("address").Value

                    , in_date = node.Attributes.GetNamedItem("date").Value                     

                    , in_memo = text//node.Attributes.GetNamedItem("text").Value 

                    , in_name = node.Attributes.GetNamedItem("contact_name").Value 

                    , in_type = "null"//node.Attributes.GetNamedItem("type").Value                     

                    , in_readable_date = node.Attributes.GetNamedItem("readable_date").Value

                });

            }

728x90
반응형