0

I have xml file in string. I do not have right to write on disk. how to pass this string to XPathDocument?

XPathDocument Doc = new XPathDocument(xmlFile);

2 Answers 2

2

It's easier to use XDocument instead of XPathDocument:

XDocument doc = XDocument.Parse(s);
Sign up to request clarification or add additional context in comments.

Comments

0

You should be able to accomplish this by converting the string to a stream, then using the XPathDocument(Stream) constructor:

string xmlFile;  // TODO get string
byte[] byteArray = Encoding.ASCII.GetBytes( xmlFile );
MemoryStream stream = new MemoryStream( byteArray );
var Doc = new XPathDocument( stream );

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.