日期:2014-05-20  浏览次数:20709 次

请问在linq to xml中类似XmlDocument.InnerXml属性相同功能语句是什么
如题: byte[] contentBytes = _internalCodepage.GetBytes(document.InnerXml)中想将document.InnerXml想替换为linq to xml请问应如何做,document.InnerXml返回的是string类型。

------解决方案--------------------
C# code

            XDocument xml = new XDocument(
                new XElement("Parent",
                    new XElement("Child1","Child1 Data"),
                    new XElement("Child2","Child2 Data")
                    )
                );
            string result = (from x in xml.Elements("Parent").Elements()
                         where x.Value == "Child1 Data"
                         select x.Value).First();
            Console.WriteLine(result);