Program with read xml in cocos2d-x 3.0

Program with read xml in cocos2d-x 3.0
0.0 0


Hi everybody !

I have a problem when upgrade to cocos2d-x 3.0.

This is my XmlReader class and my string.xml


class EGXMLReader {
	CCDictionary* m_dictionary;
	EGXMLReader(const char* dicFilename);
	const char* GetStringByKey(const char* keyword);
	static const char* GetStringByKeyFromFile(const char* dicFilename, const char* keyword);


EGXMLReader::EGXMLReader(const char* dicFilename) {
	this->m_dictionary = CCDictionary::createWithContentsOfFile(dicFilename);

EGXMLReader::~EGXMLReader() {

const char* EGXMLReader::GetStringByKey(const char* keyword) {
	return ((CCString*)(this->m_dictionary->objectForKey(keyword)))->getCString();

const char* EGXMLReader::GetStringByKeyFromFile(const char* dicFilename, const char* keyword) {
	CCDictionary *dictionary = CCDictionary::createWithContentsOfFile(dicFilename);
	return ((CCString*)dictionary->objectForKey(keyword))->getCString();


abc // If like this it’s report Assert failed: key not found : <integer/real>
abcabc // else it’s report this dictionary does not use string as key.

Someone help me. I don’t know what i wrong :frowning:


<string key="abc">abc</string> is not the standard plist format. So we don’t support it.
<key>abc</key><string>abc</string is supported. I tested it. And I did read the value of abc key.
BTW, CCDictionary was deprecated from v3.0. You could use FileUtils::getInstance()->getValueMapFromFile(filename) instead.
It will return a ValueMap which is a typedef of std::unordered_map<std::string, Value>.
To get a value for a key, you could use"key_name").