Click here to Skip to main content
12,551,373 members (50,324 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


5 bookmarked

Cinchoo - Handling nested XML files

, 10 Dec 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
Way to read the nested xml files


Cinchoo is the application framework for .NET. This article reveals one of the feature Cinchoo framework provides for developers, a.k.a reading and storing nested Xml files. .NET provides standard XmlDocument object that represents a Xml document in memory. But lacks in support of multiple sub documents files inside a Xml file. Cinchoo addresses this feature through ChoXmlDocument class, through which you can handle multiple nested Xml files. It provides an opportunities to break a large Xml document into small manageable sub-documents and use them in your applications.

How to use 

Let's assume that below is one of the large xml file you have,

<?xml version="1.0" encoding="utf-8" ?>
 <employee name="Top-Tom" state="NY" />
 <employee name="Include1-Mark" state="NM" />
 <employee name="Include11-Tom" state="MD" />
 <employee name="Include1-Tom" state="AZ" />
 <employee name="Top-Mark" state="NJ" />
Here I'm breaking them into multiple small xml files and show you how to read them using Cinchoo framework. 


This file contains one sub xml document 'XmlIncludeFile1.xml'. The sub xml file is linked using 'include' node with 'path' attribute point to a xml file path. Path can be either absolute or relative file path

<?xml version="1.0" encoding="utf-8" ?>
<employees xmlns:cinchoo="">
 <employee name="Top-Tom" state="NY" />
 <cinchoo:include path="XmlIncludeFile1.xml" />
 <employee name="Top-Mark" state="NJ" />

Below are the broken down sub XML files:


I break this file further into one more sub XML file (XmlIncludeFile11.xml). Have it linked using 'include' node. 

<?xml version="1.0" encoding="utf-8" ?>
<employee name="Include1-Mark" state="NM" />
<cinchoo:include xmlns:cinchoo="" path="XmlIncludeFile11.xml" />
<employee name="Include1-Tom" state="AZ" />


<?xml version="1.0" encoding="utf-8" ?>
<employee name="Include11-Tom" state="MD" />

Well, after having the above XML files, here is how we can load and read them in your application.

  1. Create a sample VS.NET (.NET Framework 4.0) Console Application project.   
  2. Add reference to Cinchoo.Core.dll. (Download Cinchoo framework binary here.) 
  3. Use the Cinchoo.Core.Xml namespace.
  4. Below is the code to read the above xml file
using (ChoXmlDocument xmlDocument = new ChoXmlDocument("C:\XmlTop.xml"))
That's all. Now you can access the nodes of XML document elements using ChoXmlDocument.XmlDocument. It is of type System.Xml.XmlDocument. Try for yourself.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionHow about XSD.exe? Pin
CoderPanda27-Feb-14 19:27
professionalCoderPanda27-Feb-14 19:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161021.1 | Last Updated 10 Dec 2012
Article Copyright 2012 by Cinchoo
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid