C#加載XML方式


//path:xml文件路徑  SECSMessage:xml文件的根元素下的第一個子集元素

<SECSLibrary>

  <SECSMessage>

    <Description name="hello">

      hello

    </Description>

  </SECSMessage>

  <SECSMessage>

  </SECSMessage>

</SECSLibrary>

var xmlDocument = XDocument.Load(path).Root.Elements("SECSMessage");

foreach (var msg in xmlDocument)
{

  msg.Element("Description").Value;

  //同理,也可以獲取相應的屬性值

  msg.Attribute("name“).Value;

}

 


免責聲明!

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



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