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"">
		        <DocMessage><Base64Document>varFileNrValue_0</Base64Document></DocMessage>
		        <DocMessage><DocIdentification>varFileNrValue_1</DocIdentification></DocMessage>
		        <DocMessage><ID1>varFileNrValue_2</ID1></DocMessage>  
		        </ns0:Root>");

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

Open in new window

ZURINETAsked:
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.

käµfm³d 👽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?
0
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

0
käµfm³d 👽Commented:
Sorry, I still don't understand what the goal here is.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

käµfm³d 👽Commented:
Perhaps if you post an "after" XML example. We have the "before" above.
0
ZURINETAuthor Commented:
Hi
The goal is this
I need to programatically
1. create an xml document in C# programme
2. populate the elements with values.

Example

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

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           
0
käµfm³d 👽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

0

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
C#

From novice to tech pro — start learning today.