I have a situation where I need to generate the below XML dynamically in my C# code. For example, the XML text would be
<Envelope>
<Body>
<Login>
<USERNAME>username</USERNAME>
<PASSWORD>Sm@rt123</PASSWORD>
</Login>
</Body>
</Envelope>
The requirement is to send the above XML format as a string to an API call, which would get some responses as a string in the XML format.
My question is the above example is for a Login Api call, for all the api calls, the elements Envelope and Body are same and based on the api call, the other parts change like for Login api, I need to mention a xml element as Login with its attributes username and password.
Till now I have been hardcoding the above string and trying to test if the functionality is working fine, but now I need to automate this process of generating these tags for respective different api calls. I need to know how can this be done and what is the best approach for the same.