enum order

CSharp · Console

/Program.cs

using System;
using System.Collections.Generic;
using System.Xml.Linq;
using System.Xml;

namespace ConsoleApplication1
{
    public class Program
    {
		static string xml = @"<?xml version = ""1.0"" encoding = ""utf-8""?>
<root>
    <batch> 
    <field   level = ""batch"" name = ""VoucherNumber"" value = ""00018""/>
    <field   level = ""batch"" name = ""FinancialYear"" value = ""1996""/>
    <field   level = ""batch"" name = ""CountNumber"" value = ""00018""/>
    <field   level = ""batch"" name = ""CountDate"" value = ""1416-08-16""/>
    <field   level = ""batch"" name = ""Total"" value = ""214000.0""/>
    <field   level = ""batch"" name = ""CuttOf"" value = ""0.0""/>
    <field   level = ""batch"" name = ""Net"" value = ""214000.0""/>
    <field   level = ""batch"" name = ""Comment"" value = ""1""/>
    <field   level = ""batch"" name = ""DailyNumber"" value = ""00018""/>
    <field   level = ""batch"" name = ""DailyDate"" value = ""1416-09-01""/>
    <field   level = ""batch"" name = ""Year"" value = ""1416""/>
    <field   level = ""batch"" name = ""Section"" value = ""1""/>
    </batch> 
</root>";
		
        public static void Main(string[] args)
        {            
			string str = "";
			XDocument doc = XDocument.Parse(xml);
            IEnumerable<XElement> rows = doc.Root.Descendants("field");
            foreach (XElement node in rows)
            {
                str += node.Attribute("name").Value + node.Attribute("value").Value;
            }
            Console.WriteLine(str);
        }
		
		
    }
}
;