如何在Xpath中为XDocument提供xml字符串
我有一个字符串形式的xml文件。 我没有在磁盘上写东西的权利。 如何将此字符串传递给XPathDocument如何在Xpath中为XDocument提供xml字符串,xml,c#-4.0,xpath,Xml,C# 4.0,Xpath,我有一个字符串形式的xml文件。 我没有在磁盘上写东西的权利。 如何将此字符串传递给XPathDocument XPathDocument Doc=新的XPathDocument(xmlFile) 使用XDocument而不是XPathDocument更容易: XDocument doc = XDocument.Parse(s); 通过将字符串转换为流,然后使用: string xmlFile; // TODO get string byte[] byteArray = Encoding.A
XPathDocument Doc=新的XPathDocument(xmlFile) 使用XDocument而不是XPathDocument更容易:
XDocument doc = XDocument.Parse(s);
通过将字符串转换为流,然后使用:
string xmlFile; // TODO get string
byte[] byteArray = Encoding.ASCII.GetBytes( xmlFile );
MemoryStream stream = new MemoryStream( byteArray );
var Doc = new XPathDocument( stream );