tomevika tomevika - 3 months ago 17
C# Question

How to save an XmlDocument object when you don't know path where it is getting stored?

I have one

XPathDocument
object. Which I convert to
XmlDocument
object using:

XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(doc.CreateNavigator().ReadSubtree());


Now I have updated this
xmldoc
object and trying to save using
Save
method. But it expects a
string
which I don't know.

How should I save my changes to this? Please suggest. Thanks.

Answer Source

Try this:

 XPathDocument result = new XPathDocument((doc.CreateNavigator().ReadSubtree()));