2

I have an XMl string in a Field of a mySQL Table. I load an XMLdocument (xmlDoc) from that string I then Search for a node and change an attribute. All good in here.

Then I want to save changes that i made to the XMLDocument in string format so i can update my table in the DB. How can I do this.?

If I execute xmldoc.save(), well, it will save a XML file. How can I save the changes that I have made but instead of savig the file, save it as a string so I can save it in my table.

I really do not want to parse the XML string as a normal string to search my parameters and save it.

I am working on vb.net, but if you have code in other .net lang, no problem. The DB is in MySQL

Dany
  • 131
  • 3
  • 17

1 Answers1

5

Sorry it's C#, but you'll get the idea. Do something like:

    XmlDocument dom = new XmlDocument();
    dom.LoadXml("<test><cases><case id='2'>one</case></cases></test>");
    dom.SelectSingleNode("/test/cases/case[1]").Attributes["id"].InnerText = "1";
    string x = dom.OuterXml;

And then use x to update the database field.

Andrew Cowenhoven
  • 2,778
  • 22
  • 27