c# 讀取xml文件子節點


xml文件如圖:

<ROOT>
<Info>
<ProjectGuid>E6101000801000132</ProjectGuid>
<ProjectName>西安工程大學文體樓項目</ProjectName>
<Date>2019-04-24 11:06:43</Date>
</Info>
</ROOT>

代碼獲取:

方法一:

XmlDocument xml = new XmlDocument();
xml.Load(Application.StartupPath + \\Info.xml");
XmlNodeList nodeList = xml.SelectNodes("/ROOT/Info");
foreach (XmlNode item in nodeList)
{
   XmlNodeList Lists= item.ChildNodes;
   foreach (XmlNode List in Lists)
   {
      if (List.Name== "ProjectGuid")
      {  
         string str=List.InnerXml;
      }
   }
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM