从字符串创建XElement

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从字符串创建XElement相关的知识,希望对你有一定的参考价值。

Reading xml from file and create XElement from string
  1. // read xml document from file to a string
  2. string s_xml = System.IO.File.ReadAllText("deneme.xml");
  3.  
  4. // create xelement from string
  5. XElement e = XDocument.Parse(s_xml).Root;
  6.  
  7. //then take value of a field you need
  8. string HeaderVersion = e.Element("HeaderVersion").Value;

以上是关于从字符串创建XElement的主要内容,如果未能解决你的问题,请参考以下文章