Hashmat Ali
Hashmat Ali

Reputation: 1

How to read large number of XML files from file system

Lets assume, I have set of countries (more than 100). Each country can have many states. Each State will have one xml file in the file system. I have to search these xml files based on parameters like country,State or any Id which is present in the xml file.

xml file structure in the file system:

<Country code="in">
    <States Name="Delhi">
        <Subscriptions>
                <Subscription Id="100" Code="ABC">
                         ...
                        </Subscription>
                        <Subscription Id="101" Code="XYZ">
                         ...
                        </Subscription>
            </Subscriptions>
        </States>
</Country>

File structure (country folder -> State folder -> Subscription.xml file) :

US -> California-> Subscription.xml
US -> Alaska-> Subscription.xml
In -> Delhi -> Subscription.xml
In -> Tamil Nadu -> Subscription.xml

. . .

e.g: if a user search for id = 100, I have to look in each country folder... in each States folder...in each Subscription.xml file, if an id with 100 is present or not.

Please share your thoughts on this how to achieve search functionality on this using C#.

Upvotes: 0

Views: 217

Answers (1)

Jodrell
Jodrell

Reputation: 35716

If the data is not going to change, you could just load it all into an object graph in memory and implement the searching yourself. If there 100 countries each with 100 states each with 100 subscriptions that will only total 1000000 objects which shouldn't be too onerous.

If you want to support changes to the data then you are going to need a database of some kind.

If you want the search you perform to be flexible or if you might want to tweak the schema later I would suggest a database again.

Upvotes: 3

Related Questions