5

How to generate the below XML lines from C# 2015

 2 years ago
source link: https://www.codeproject.com/Questions/5319838/How-to-generate-the-below-XML-lines-from-Csharp-20
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Hi,
Iam using vs2015. From C# I need to generate the XML file. Really I am very new to XML.
The tried the codes generates the XML file nicely.

Copy Code
using namespace System::Xml;

    	XmlDocument^ Doc = gcnew XmlDocument();
		XmlDeclaration^ MyXmlDeclare = Doc->CreateXmlDeclaration("1.0", nullptr, nullptr);
		XmlElement^ MyRoot = Doc->DocumentElement;
		Doc->InsertBefore(MyXmlDeclare, MyRoot);

		XmlElement^ MyElement1 = Doc->CreateElement(String::Empty, "ENVELOPE", String::Empty);
		Doc->AppendChild(MyElement1);

		Doc->Save("C:\\Temp\\MyTallyPrgXML.xml");

But I get struck for the below XML lines. But I need it to generate it from C# 2015.
Kindly advice me to get succeed. Thanks
Copy Code
<TALLYMESSAGE xmlns:UDF="TallyUDF">
  <VOUCHER VCHTYPE="Sales" ACTION="Create">
     <VOUCHERTYPENAME>Sales</VOUCHERTYPENAME>
     <ALLLEDGERENTRIES.LIST>
        <REMOVEZEROENTRIES>No</REMOVEZEROENTRIES>
        <ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE>
        <LEDGERFROMITEM>No</LEDGERFROMITEM>
        <LEDGERNAME>Customer 1</LEDGERNAME>
        <AMOUNT>-5000</AMOUNT>
     </ALLLEDGERENTRIES.LIST>
  </VOUCHER>
</TALLYMESSAGE>


What I have tried:

I tried to generate the XML file from C# 2015.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK