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

2
  • What is an XMLdoc? I've never heard of such a class. Commented Mar 28, 2011 at 20:42
  • What Andrew Cowenhoven post was what i was looking for, Thank you all for the quick response! Commented Mar 28, 2011 at 21:34

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Indeed, this is the answer. Thank you very much Andrew!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.