Reading xml / plist file coco2d-x 3.9

i have a plist file with level data in it for for game objects i am able to read in the file as a value my problem is i cant seem to be able to figure out how to read the different keys to get the value i want for the different objects.

this is my plist file. as you can see i have a key for “Blocks” and its values and “Enemies” and their values

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">  
<array>
<dict>
	<key>blocks</key>
	<array>
		<dict>
			<key>x</key>
			<real>100</real>
			<key>y</key>
			<real>600</real>
		</dict>
		<dict>
			<key>x</key>
			<real>300</real>
			<key>y</key>
			<real>20</real>
		</dict>
		<dict>
			<key>x</key>
			<real>0</real>
			<key>y</key>
			<real>1</real>
		</dict>
	</array>
	<key>enemies</key>
	<array>
		<dict>
			<key>lane</key>
			<real>0</real>
			<key>speed</key>
			<real>4</real>
		</dict>
		<dict>
			<key>lane</key>
			<real>1</real>
			<key>speed</key>
			<real>1</real>
		</dict>
		<dict>
			<key>lane</key>
			<real>2</real>
			<key>speed</key>
			<real>9</real>
		</dict>
		<dict>
			<key>lane</key>
			<real>0</real>
			<key>speed</key>
			<real>2</real>
		</dict>
	</array>
</dict>
 </array>
</plist>

and to read this in i am using

std::string levelsFile = FileUtils::getInstance()->fullPathForFilename("../../Resources/levels.plist");

ValueVector m_levels = FileUtils::getInstance()->getValueVectorFromFile(levelsFile);

for (auto levelData : m_levels){
    auto data = levelData.asValueMap();

    log("The description of the string value : %s", levelData.getDescription().c_str());


    block.at(i)->create(Vec2(
        ladderdata["x"].asInt(),
	ladderdata["y"].asInt()
	), this);
}

Thanks in advance to any one that helps

You would be so much better off using Json and a nice library

Then you can host your source files on a website, serve them up via rest/json api, publish new levels through your website etc. The json syntax is so much cleaner and leaner than plist xml

Managed to get it working easy enough in the end…

As i am currently only working on small assignment for college wont be using Json but it is something i plan to do in future and you just saved me searching for a library… Thanks :smile: