我将像这样传递 xml 文件:
File1.PostedFile.InputStream
//reading xml file.....
public static void readXMLOutput(Stream stream)
{
System.Xml.Linq.XDocument xml = System.Xml.Linq.XDocument.Load(stream);
var query = from p in xml.Element("ste").Element("Application")
//where (int)p.Element("Id") == 1
select Page;
foreach (var record in query)
{
Response.Write("dfe") + record.Element("dfe").Value;
}
error:
错误 1 “System.Xml.Linq.XDocument.Load(string)”的最佳重载方法匹配有一些无效参数
无法从“System.IO.Stream”转换为“字符串”
您是否使用过 .NET 3.5?XDocument.Load(Stream)
显然只出现在 .NET 4 中。
您可能想使用过载需要一个XmlReader http://msdn.microsoft.com/en-us/library/bb356384.aspx(3.5 中支持)。
编辑:示例代码:
static XDocument LoadFromStream(Stream stream)
{
using (XmlReader reader = XmlReader.Create(stream))
{
return XDocument.Load(reader);
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)