From the course: .NET Essentials: LINQ for XML

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Save the XML document

Save the XML document - .NET Tutorial

From the course: .NET Essentials: LINQ for XML

Start my 1-month free trial

Save the XML document

- [Instructor] When you make changes to the XML data, you may need to save the update. When the data originated in a file, we should save it to the file. So that's what we'll look at in this example. How to use the save method. And I'm working with a simpler XML file this time, the card's simple. So let's run these five lines of code. And this is what we see. I have a card and I'm going to be changing the slogan. And currently it's Double Trouble. And I'll change the publish date, currently it's in 2007. So I'll change those two pieces of information. So that's what I'm doing here on line nine and 10. Don't worry too much about this, we'll talk more about the details later in the course. I'm calling set element value. I'm passing in the name of the element and the new value Triple Trouble. And here I'm setting the publish date to a date in 2019. And then I'm going to dump out the information here that shows the changes.…

Contents