Skip to content

QuickXmlLoad

Cinchoo edited this page Jun 24, 2017 · 12 revisions

Loading Xml file

To load Xml file, use ChoXmlReader component to parse it. Sample below shows how to load Xml file (Emp.xml)

<Employees>
    <Employee Id='1'>
        <Name>Tom</Name>
    </Employee>
    <Employee Id='2'>
        <Name>Mark</Name>
    </Employee>
</Employees>

Load using iterator

foreach (dynamic e in new ChoXmlReader("Emp.xml"))
    Console.WriteLine("Id: " + e.Id + " Name: " + e.Name);

Load using loop

var reader = new ChoXmlReader("Emp.xml");
dynamic rec;
 
while ((rec = reader.Read()) != null)
    Console.WriteLine("Id: " + e.Id + " Name: " + e.Name);

Load using POCO object

public class Employee
{
    public int Id { get; set; }
    public string Name { get; set; }
}
foreach (var e in new ChoXmlReader<Employee>("Emp.xml"))
    Console.WriteLine("Id: " + e.Id + " Name: " + e.Name);

Please visit below article for detailed walk-through of Xml file reader

Cinchoo ETL - Xml Reader