Overwrite xml document value

Hi all
How can I overwrite a value of an xml document attribute
after its creation?

The code below need editing
XmlDocument  varBase64MsgXMLDOM = new System.Xml.XmlDocument();
varBase64MsgXMLDOM.LoadXml(@"<ns0:Root xmlns:ns0=""http://schemas.Transaction/Credit/Encoder"">

                varBase64MsgXMLDOM.DocMessage.Base64Document = varBase64String;
                varBase64MsgXMLDOM.DocMessage.DocIdentification = varDocIdentification;
                varBase64MsgXMLDOM.DocMessage.ID1 = varTransactionID;

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kaufmed   ( ͡° ͜ʖ ͡°)*whispers*  I C# people.Commented:
You requirement is unclear. Your XML doesn't have any attributes except for the prefix declaration on the root node ( xmlns:ns0= ... ). Is this what you are referring to?
ZURINETAuthor Commented:
Hoi Kaufmed

The above code is correct ..
I have a root  = Root
Child node DocMesage
3 elements : with default values ;Base64Document, DocIdentification and ID1
In Biztalk Orchestration the code works..
I need to get it working in a C# class

kaufmed   ( ͡° ͜ʖ ͡°)*whispers*  I C# people.Commented:
Sorry, I still don't understand what the goal here is.
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

kaufmed   ( ͡° ͜ʖ ͡°)*whispers*  I C# people.Commented:
Perhaps if you post an "after" XML example. We have the "before" above.
ZURINETAuthor Commented:
The goal is this
I need to programatically
1. create an xml document in C# programme
2. populate the elements with values.


Namepspace = :ns0=""http://schemas.Transaction/Credit/Encoder
Root Node = Root
SubNode = DocMessage
Elements or attributes = Base64Document

Append values for Base64Document  from variable = varBase64String;
Append values for DocIdentification from variable = varDocIdentification;
Append values for ID1  from variable = varTransactionID;

And finally retrun the xml document as string.

If you need more info please let me know           
kaufmed   ( ͡° ͜ʖ ͡°)*whispers*  I C# people.Commented:
I think this is what you are asking:
static string GetXML(string varBase64String, string varDocIdentification, string varTransactionID)
    XmlDocument xdoc = new XmlDocument();
    XmlNode root = xdoc.AppendChild(xdoc.CreateElement("ns0", "Root", "http://schemas.Transaction/Credit/Encoder"));
    XmlNode child = root.AppendChild(xdoc.CreateElement("DocMessage"));

    child.AppendChild(xdoc.CreateElement("Base64Document")).InnerText = varBase64String;
    child.AppendChild(xdoc.CreateElement("DocIdentification")).InnerText = varDocIdentification;
    child.AppendChild(xdoc.CreateElement("ID1")).InnerText = varTransactionID;

    return xdoc.InnerXml;

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.