0
我有字符串中的xml文件。 我沒有權利在磁盤上寫入。 如何將此字符串傳遞給XPathDocument?如何在Xpath中將xml字符串提供給XDocument
XPathDocument Doc = new XPathDocument(xmlFile);
我有字符串中的xml文件。 我沒有權利在磁盤上寫入。 如何將此字符串傳遞給XPathDocument?如何在Xpath中將xml字符串提供給XDocument
XPathDocument Doc = new XPathDocument(xmlFile);
它更容易使用,而不是XPathDocument中的XDocument:
XDocument doc = XDocument.Parse(s);
您應該能夠通過字符串轉換成流,然後使用XPathDocument(Stream) constructor來實現:
string xmlFile; // TODO get string
byte[] byteArray = Encoding.ASCII.GetBytes(xmlFile);
MemoryStream stream = new MemoryStream(byteArray);
var Doc = new XPathDocument(stream);