Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
XML
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ns2="http://gl.ws.apps.oracle.xxdof/">
   <env:header>
      <ns1:security>
         <ns1:usernametoken>
            <ns1:username>XXXX
            <ns1:password>YYYYYYY
         
      
   
   <env:body>
      <ns2:getgldetails>
         <arg0>
            <p_from_date>01-01-2018

            <p_group_id>
             <p_je_category>Payments

            <p_je_source>SOURCE
            <p_ledger_name>OU
            <p_to_date>31-12-2018


I want to create xml file in C# as same as above xml format. Body section will be extracted from DB and mapped it to respective tags. kindly help me to solve this issue

What I have tried:

I tried by using Xml serialization using below code to convert the data to XML. But the output is in different.

C#
var serxml = new System.Xml.Serialization.XmlSerializer(GLGetrequest.arg0.GetType());
                var ms = new MemoryStream();
                serxml.Serialize(ms, GLGetrequest.arg0);
                string xml = Encoding.UTF8.GetString(ms.ToArray());
                XmlDocument Add_XMLDoc = new XmlDocument();
                XmlNode Add_XMLDoc_Node = null;
                Add_XMLDoc.LoadXml(xml);
Posted
Updated 8-Nov-18 23:27pm
v3
Comments
Afzaal Ahmad Zeeshan 9-Nov-18 4:02am    
And the problem with the code is?

1 solution

<?xml version="1.0"?>

-<getGLDetailsInp xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<p_FROM_DATE>01-01-2018</p_FROM_DATE>

<p_GROUP_ID/>

<p_JE_CATEGORY>Payments</p_JE_CATEGORY>

<p_JE_SOURCE>SOURCE</p_JE_SOURCE>

<p_LEDGER_NAME>OU</p_LEDGER_NAME>

<p_TO_DATE>31-12-2018</p_TO_DATE>

</getGLDetailsInp>


I'm not getting output as an provided xml. Dont know how to add headers and exact xmlns node given...
 
Share this answer
 
Comments
Patrice T 9-Nov-18 4:56am    
Use Improve question to update your question.
So that everyone can pay attention to this information.
and delete this solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900