Skip to main content
gamedev.net
🔒 Locked

Creating Tree's from XML

Started by gimp Jun 19, 2002 at 2:41 AM 0 replies 200+ views
Original Post
gimp
gimp
My application needs to load data from a text file and create a tree structure. Here is a simple example xml file:
<form Name=Empty" Position="60 100" Dimensions="600 400">
	
	
	

 
(Yes the coordinate system up upside down) What I currently do is use Expat to parse the file and create an object from each element. I then collect the attributes from each element and pass them to a member of the base object class ''SetAttributes'' which will configure the object based on the attributes of the element. SetAttributes receives a ref to a map. It works. It''s not exactly fast but was good enough to get my by... Questions: -Passing in attributes like this is slow and ugly. I can''t think of anything better besides just passing in some pointers and forcing each class to scan the attribute array for attributes it knows about. Which is probably slower than building a map for each object anyway... -Is this even a good mechanism? Can you think of a better way of turning XML data in to objects with settings. (NOTE : I''ve just started looking in to using Xerces rather than Expat listed above.) Many thanks, Chris Brodie http:\\fourth.flipcode.com
Chris Brodie
JonStelly
JonStelly
No mention of language, and your XML didn't show up right. But it looks like it's a template for a GUI dialog box or something, right?
If so, why try to open it, convert it to a tree, then convert it somewhere else to create the dialog? Why not just go straight from XML to Dialog?


    
<form Name=Empty" Position="60 100" Dimensions="600 400">
<Button Image="
Menu\Close.tga" Position="584 384" Dimensions="16 16" Command="DeactivateParent" />
<DragPad Position="
0 384" Dimensions="584 16" Image="Menu\DragPad.tga" />
<HotKey Key="
KEY_HOME" Command="ActivateParent" />
</Form>



[edited by - jonstelly on June 19, 2002 10:42:05 AM]

[edited by - jonstelly on June 19, 2002 10:42:18 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.