Hi namojainashis...,
Load the XmlDocument from the xml string. Then using Save method save id as xml file.
Refer below code.
C#
protected void Page_Load(object sender, EventArgs e)
{
string xml = "<Document_Input>";
xml += "<documentName>139459_AE_IE_SC Contract_V36</documentName>";
xml += "<documentLocation>UploadToDMS/139459/139459_AE_IE_SC Contract_V36.pdf</documentLocation>";
xml += "<documentExtension> pdf</documentExtension>";
xml += "<parentFolderName>AE_IE_SC Contract</parentFolderName>";
xml += "<pathToRoot>test/Projects/139459</pathToRoot>";
xml += "<dataDefName>MDMS</dataDefName>";
xml += "<docFields/>";
xml += "<docField>";
xml += "<fieldName>Organization</fieldName>";
xml += "<fieldValue>text</fieldValue>";
xml += "</docField>";
xml += "<docField>";
xml += "<fieldName>Subject</fieldName>";
xml += "<fieldValue></fieldValue>";
xml += "</docField>";
xml += "<docField>";
xml += "<fieldName>Section</fieldName>";
xml += "<fieldValue></fieldValue>";
xml += "</docField>";
xml += "<docField>";
xml += "<fieldName>Document_Type</fieldName>";
xml += "<fieldValue>AE_IE_SC Contract</fieldValue>";
xml += "</docField>";
xml += "<docField>";
xml += "<fieldName>Document_ID</fieldName>";
xml += "<fieldValue>139459_AE_IE_SC Contract_V36</fieldValue>";
xml += "</docField>";
xml += "</Document_Input>";
System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
xdoc.LoadXml(xml);
xdoc.Save(Server.MapPath("~/Document.xml"));
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim xml As String = "<Document_Input>"
xml += "<documentName>139459_AE_IE_SC Contract_V36</documentName>"
xml += "<documentLocation>UploadToDMS/139459/139459_AE_IE_SC Contract_V36.pdf</documentLocation>"
xml += "<documentExtension> pdf</documentExtension>"
xml += "<parentFolderName>AE_IE_SC Contract</parentFolderName>"
xml += "<pathToRoot>test/Projects/139459</pathToRoot>"
xml += "<dataDefName>MDMS</dataDefName>"
xml += "<docFields/>"
xml += "<docField>"
xml += "<fieldName>Organization</fieldName>"
xml += "<fieldValue>text</fieldValue>"
xml += "</docField>"
xml += "<docField>"
xml += "<fieldName>Subject</fieldName>"
xml += "<fieldValue></fieldValue>"
xml += "</docField>"
xml += "<docField>"
xml += "<fieldName>Section</fieldName>"
xml += "<fieldValue></fieldValue>"
xml += "</docField>"
xml += "<docField>"
xml += "<fieldName>Document_Type</fieldName>"
xml += "<fieldValue>AE_IE_SC Contract</fieldValue>"
xml += "</docField>"
xml += "<docField>"
xml += "<fieldName>Document_ID</fieldName>"
xml += "<fieldValue>139459_AE_IE_SC Contract_V36</fieldValue>"
xml += "</docField>"
xml += "</Document_Input>"
Dim xdoc As System.Xml.XmlDocument = New System.Xml.XmlDocument()
xdoc.LoadXml(xml)
xdoc.Save(Server.MapPath("~/Document.xml"))
End Sub
Generated xml file
<Document_Input>
<documentName>139459_AE_IE_SC Contract_V36</documentName>
<documentLocation>UploadToDMS/139459/139459_AE_IE_SC Contract_V36.pdf</documentLocation>
<documentExtension> pdf</documentExtension>
<parentFolderName>AE_IE_SC Contract</parentFolderName>
<pathToRoot>test/Projects/139459</pathToRoot>
<dataDefName>MDMS</dataDefName>
<docFields />
<docField>
<fieldName>Organization</fieldName>
<fieldValue>text</fieldValue>
</docField>
<docField>
<fieldName>Subject</fieldName>
<fieldValue>
</fieldValue>
</docField>
<docField>
<fieldName>Section</fieldName>
<fieldValue>
</fieldValue>
</docField>
<docField>
<fieldName>Document_Type</fieldName>
<fieldValue>AE_IE_SC Contract</fieldValue>
</docField>
<docField>
<fieldName>Document_ID</fieldName>
<fieldValue>139459_AE_IE_SC Contract_V36</fieldValue>
</docField>
</Document_Input>
Note: Make sure you have valid xml string.