切记:保存的XML中的编码必须是UTF-8,不然照样乱码,因此保存时先检查是否是UTF-8,别弄成默认的ANSI了!!!
<1>XML格式如下:
<dict> <key>language</key> <string>English</string> <key>username</key> <string>偶尔e网事</string> <key>website</key> <string>CSDN博客:http://blog.csdn.net/jackystudio</string> </dict>
<2>访问XML代码如下:
/* 访问XML文件来显示中文 */ CCDictionary *chnStrings = CCDictionary::createWithContentsOfFile("CHN_Strings.xml"); chnStrings->retain(); const char *username = ((CCString*)chnStrings->objectForKey("username"))->m_sString.c_str(); CCLabelTTF* pLabel = CCLabelTTF::create(username,"Arial",24);//这里创建一个文本 pLabel->setPosition(ccp(origin.x + visibleSize.width/2,origin.y + visibleSize.height - pLabel->getContentSize().height)); this->addChild(pLabel,1);原文链接:https://www.f2er.com/xml/298445.html