从c#代码确定xml结构

时间:2017-08-03 06:30:46

标签: c# xml

是否可以通过读取C#代码来准确地确定XML文件的结构。

代码:

XmlDocument xDoc = new XmlDocument();
            xDoc.Load(AppDomain.CurrentDomain.BaseDirectory + "\\Contacts.xml");

            XmlNodeList nodeList = xDoc.SelectNodes("/ContactsList/Group[@Name='" + group_name + "']");

            if (nodeList[0].ChildNodes[2].InnerText != "NA")
            {
                if ((now < start) || (now > end))
                {
                    primary_number = nodeList[0].ChildNodes[2].InnerText;
                }
                else
                    primary_number = nodeList[0].ChildNodes[0].InnerText;

            }
            else
                primary_number = nodeList[0].ChildNodes[0].InnerText;


            if (nodeList[0].ChildNodes[3].InnerText != "NA")
            {
                if ((now < start) || (now > end))
                {
                    secondary_number = nodeList[0].ChildNodes[3].InnerText;
                }
                else
                    secondary_number = nodeList[0].ChildNodes[1].InnerText;
            }
            else
                secondary_number = nodeList[0].ChildNodes[1].InnerText;

        }

我无法找到xml文件,我正在尝试重现Contacts.xml文件的结构。

0 个答案:

没有答案
相关问题