I have a XML world map which basically takes two inputs (its a XML file with corresponding CSS files and stuff): the country input and country address. So when I manually enter the data into the XML file (Country name and country address) the country on the map changes its color and on hovering over that country I can see what I've entered.
I have a list of all countries in my DB. So I was thinking of there is any way for me to write in all those countries from my DB into the XML file. I was thinking of something like this:
for(int i=0; i<list.count;i++)
{
list[i].CounryName = //write it into the XML file;
list[i].CountryUserAddress = //Write it into the XML file;
}
So the idea is to when the for loop goes on and on, every country is written in into the XML file. I don't have any significant experience working with XML files in ASP.NET and I'm stuck on dry land here. All this should be done via code behind. Can someone help me out with this, or at least point me into the right direction?
Thanks heaps!
P.S. I've forgot to mention that I should be actually overwriting the already existing XML file, not creating a new one...
Here's an example of how you could do this with the data you provided:
The general idea is to traverse the document's tree and select that value to update. There may be a better way to do this, but this is the way I'm familiar with. Similarly, you can create an xml document in the same manner.
The subject matter is different, but this helped me tremendously in understanding reading/writing XML data: this link
EDIT: I updated the code slightly to make the parent element "CountryList" and append each "Country" in the DB to that. The document will end up coming out something like: