C# .NET - Dynamic XML - Asked By Kalpana Natarajan on 29-Oct-18 10:09 AM

Hi All,

I wanna create a Dynamic XML using C#.

Below is the format:

<CMGMessage>

 <MsgHeader Version="0201">

  <AppName>Service Name</AppName>

  <UserID>App Name</UserID>

  <OriginTS>YYYY-MM-DD-HH.MM.SS</OriginTS>

  <MsgType>

   <Request/>

  </MsgType>

 </MsgHeader>

 <MsgBody Version="0201">

  <Events>

   <Event>

  <REQST_ID>#####</REQST_ID>

  <EVNT_ID>EventID</EVNT_ID>

  <JRNL_DT>MM/DD/YYYY</JRNL_DT>

  <AMOUNT>###.##</AMOUNT>

  <CU_NR>########</CU_NR>

  <SRC_REF_ID>XXXXX</SRC_REF_ID>

   </Event>

   …

  </Events>

 </MsgBody>

</CMGMessage> 

Here Event Child node will be repeating according to input and this has to be dynamically happen. Anyone please answer

Robbe Morris replied to Kalpana Natarajan on 29-Oct-18 05:59 PM
Start with the System.Xml namespace and an XmlDocument class.  From there, you would append XmlNode child nodes as needed.
Kalpana Natarajan replied to Robbe Morris on 29-Oct-18 07:58 PM
Robbie,

Thanks for your reply. I'm trying in the same way. But its not coming in the same way as expect. Because I need version mentioned in particular child node.

Thank you