Sign in to follow this  
newbie8787

[C#] Generic XML Parser

Recommended Posts

[This is a repost of a topic started in the general programming section] Hello All, I had made a 2D Point and click game a little while ago , the catch to it was that the game used to parse XML files to generate scenes, so the whole system was configurable and you could make new games just by editing the XML files. However I have come to realize that the way in which we did XML parsing was ... well ... stupid [:P] , basically we hard-coded each XML file structure into our program and then read data from XML fields into objects of the classes we had made (with the hard-coded structures). This method , I think is not scalable at all and is also increasing the code volume by a lot (there are any classes). I was wondering if there is any way to automatically parse and create objects from XML files themselves ? So that no data pertaining to the XML files ever needs to be coded into the program. Kinda lie a black box , into which you put an XML file and creates an (or more) objects for you with the names as given in the XML. EDIT : I think my initial post was a bit too ambiguous , I wanted to clarify something further, I DO NOT want the xml files to just be parsed and be left with the data in the files. I WANT : 1. The File to be parsed 2. The data to be fetched 3. Objects to be created using the tag names as in the XML eg. If my XML was <This_is_My_XML> <Attrib_1> </Attrib_1> <Attrib_2> <Attrib_3> </Attrib_3> </Attrib_2> </This_is_My_XML> Then I would want the Parsing system to create an object of type : This_is_My_XML which would have data members : Attrib_1 Attrib_2 (Which itself is an object of type Attrib_2 and has Attrib_3 as a data member) and so on. Is what I am saying even possible ?

Share this post


Link to post
Share on other sites
Quote:
Original post by newbie8787
[This is a repost of a topic started in the general programming section]


I noticed. We don't like that on our forums. One section per topic, please. (This is definitely General rather than Game material anyway.)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this