Game Development Community

Reading XML Files Broken?

by Chris Haigler · in Torque Game Builder · 12/30/2012 (9:57 am) · 1 replies

Is anyone else able to read XML files (via xml.cs/SimXmlDocument) using 1.7.6? I can't seem to get SimXmlDocument to load any files from anywhere (including commonConfig.xml in the %appData% directory). Even the template games (BehaviorShooter, etc.) using a clean install of 1.7.6 don't properly read their commonConfig files. Instead, the games launch, fail to find commonConfig and use the default settings (which are then saved to commonConfig when the game closes).

I've stepped through the C++ code and found that the engine does find and load the xml file and properly passes it off to tinyxml for parsing. Somewhere along the line tinyxml fails with an "Error reading Element value" error.

I did find this thread: http://www.garagegames.com/community/forums/viewthread/71259 from 2008 which seems consistent with what I'm seeing on my end but Kevin's "fix" for the issue doesn't work for me (and is actually worse because it prevents SimXmlDocument from reading files from the project directory).

So:

* Saving XML files (to the %appData% directory, of course) works.
* Reading XML files from any location fails.
* FileObject can write AND read files.

#1
12/30/2012 (8:54 pm)
Ugh. Spent most of the day trying to track this one down only to realize the issue was with the custom commonConfig.xml file I was using. tinyxml was returning the "Error reading Element value" error because I had a number of elements with malformed names (<ChannelVolume[1]> rather than <ChannelVolume1>, tinyxml was tripping up on the square brackets)

So the answer to this thread is: no, reading XML files is not broken. It works perfectly fine as long as you load a valid XML file!