XML Files
BlitzMax Forums/BlitzMax Beginners Area/XML Files| 
 | ||
| Hi ppls! Im create a config/place descriptor for my game, and I want to create it using a format like XML see: [START] [WIDTH]800[/WIDTH] [HEIGHT]600[/HEIGHT] [/START] There are a especialized reader for this type of document??? How can I get this field values??? Thanks in advance! | 
| 
 | ||
| You could just use XML | 
| 
 | ||
| Using Brucey's libxml module. 
Function error(msgg:String)
	Notify msgg
End Function
Function get_doc:TxmlDoc(docname:String, rootname:String, val=False)
	If val Then If Not validate(docname) Return Null
	Local doc:TxmlDoc = TxmlDoc.parseFile(docname)
	If doc = Null Then
		doc.free()
		error docname + " not found"
		Return Null
	End If
	Local node:TxmlNode = doc.getRootElement()
	
	If node = Null Then
		doc.free()
		error docname + " empty document"
		Return Null
	End If
	
	If node.getName() <> rootname
		doc.free()
		error docname + " of wrong type; expected " + rootname + " but found " + node.getName()
		Return Null
	End If
	Return doc
End Function
Function Load()
	Local doc:TxmlDoc = get_doc("Settings.xml", "settings")
	Local root_node:TxmlNode = doc.getRootElement()
	Local xres, yres, fullscreen, depth, update_speed
	xres = Int(root_node.getAttribute("xres"))
	yres = Int(root_node.getAttribute("yres"))
	fullscreen = Int(root_node.getAttribute("fullscreen"))
	depth = Int(root_node.getAttribute("depth"))
	update_speed = Int(root_node.getAttribute("updatespeed"))
	doc.free()
End Function
.....................the file..............
<settings xres="1024" yres="768" fullscreen="0" depth="32" updatespeed="30"/> | 
| 
 | ||
| Thanks a lot !!!!! |