c – 为什么这个循环只运行一次?
发布时间:2020-12-16 10:28:15 所属栏目:百科 来源:网络整理
导读:为什么这个循环只运行一次? note DatabaseItem只接受一个节点并填充数据. xml中有3个音符. XML: ?xml version="1.0" encoding="utf-8"?noteCollection note name="Test Note 1"This is test note 1 content!/note note name="Test Note 2"This is test not
为什么这个循环只运行一次?
note DatabaseItem只接受一个节点并填充数据. xml中有3个音符. XML: <?xml version="1.0" encoding="utf-8"?> <noteCollection> <note name="Test Note 1">This is test note 1 content!</note> <note name="Test Note 2">This is test note 2 content!</note> <note name="Test Note 3">This is test note 3 content!</note> </noteCollection> C : std::vector<notekeeper::noteDatabaseItem> noteList; TiXmlElement* noteCollection = xmlDoc->FirstChildElement("noteCollection"); TiXmlElement* node = noteCollection->FirstChildElement("note"); int itemCount = 0; while (node != NULL) { itemCount++; noteList.resize(itemCount); noteList.push_back(noteDatabaseItem(node)); node = noteCollection->NextSiblingElement("note"); } 解决方法
不应该是node = node-> NextSiblingElement(“note”)?
noteCollection只有孩子,而不是兄弟姐妹,对吧? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |