Home Create XML file using c# like below format
Reply: 0

Create XML file using c# like below format

user2069
1#
user2069 Published in August 15, 2018, 9:02 am

I need to create xml using c# below format.

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
        <AddressLine1 xmlns="">50 W TOWN ST</AddressLine1>
        <AddressLine2 xmlns="">STE 400</AddressLine2>
        <City xmlns="">COLUMBUS</City>
        <State xmlns="">OH</State>
        <Zip xmlns="">43215</Zip>
        <Zip4 xmlns=""/>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope> 

Below is my c# code to create xml like above

        XmlDocument doc = new XmlDocument();
        XmlNode docNode = doc.CreateElement("SOAP-ENV:Envelope");
        XmlAttribute typeAttr = doc.CreateAttribute("xmlns:SOAP-ENV");
        typeAttr.Value = "http://schemas.xmlsoap.org/soap/envelope/";
        docNode.Attributes.Append(typeAttr);
        doc.AppendChild(docNode);

        XmlNode AddressRequestBody = doc.CreateElement("SOAP-ENV:Body");
        docNode.AppendChild(AddressRequestBody);

        ........
        ........

        XmlNode Zip4Node = doc.CreateElement("Zip4");
        typeAttr = doc.CreateAttribute("xmlns");
        typeAttr.Value = "";
        Zip4Node.Attributes.Append(typeAttr);
        Zip4Node.AppendChild(doc.CreateTextNode(""));
        AddressRequestBody.AppendChild(Zip4Node);

With the above code I am geting xml like below. missing SOAP-ENV: in Envelop and body tags. Any idea to how to get SOAP-ENV: in both Envelop and body tags. I am new to xml not sure how to get.

<Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
 <Body>
  <AddressLine1 xmlns="">Add1</AddressLine1>
  <AddressLine2 xmlns="">Add2</AddressLine2>
  <City xmlns="">City1</City>
  <State xmlns="">state1</State>
  <Zip xmlns="">zip1</Zip>
  <Zip4 xmlns=""></Zip4>
 </Body>
</Envelope>
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.306124 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO