0

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.

elirandav
  • 1,913
  • 19
  • 27
tomevika
  • 5
  • 4
  • Why are you trying to save `xmldoc`? How will you use it later? Why it is not enough to hold reference to `xmldoc`? – elirandav Jul 02 '17 at 16:38
  • I am receiving XPathDocument object from another function and have to return same once I am done with my edits in XmlElements. How else can I save changes if not using Save method? Please suggest. – tomevika Jul 02 '17 at 16:54
  • what is the return type of the function? `List`? – elirandav Jul 02 '17 at 16:57
  • Actually it is XpathDocument. It is a static xml file stored in db with some wrong data. My intention is to correct that data. The module which is being used to correct some other data uses xpathdocument object with xslt. But I have to update it without xslt and with help of C# and DOM. – tomevika Jul 02 '17 at 17:08
  • So the function gets `XpathDocument`, removes some nodes and returns `XpathDocument` with the changes? – elirandav Jul 02 '17 at 17:31
  • yes, it modify one node and should return xpathdoucment object to execute other modifications using xslt file. – tomevika Jul 02 '17 at 18:11

1 Answers1

0

Try this:

 XPathDocument result = new XPathDocument((doc.CreateNavigator().ReadSubtree()));
elirandav
  • 1,913
  • 19
  • 27