2013-03-03 2 views
0

을 이것은 XML 코드로드 :pugiXML : 형제 자매를 반복 할 수 없습니다! 첫 번째

<?xml version="1.0" encoding="utf-8"?> 
<Enemies> 
    <Enemy id="001" name="Bandit" combatstyle="1" aitype="1" difficulty="1" imgsheet="001.png" level="2" hp"5" /> 
    <Enemy id="005" name="Dragon" combatstyle="1" aitype="1" difficulty="1" imgsheet="002.png" level="5" hp"50" /> 
</Enemies> 

그리고 이것은 내가 콘텐츠를 검색하는 데 사용하는 코드의 IT :

pugi::xml_document doc; 

pugi::xml_parse_result result = doc.load_file("assets/enemies.xml");  

pugi::xml_node nodes = doc.child("Enemies"); 

for (pugi::xml_node tool = nodes.child("Enemy"); tool; tool = tool.next_sibling("Enemy")) 
    { 
     //only here to check if it's working 
     string lol = tool.attribute("name").as_string(); 
     int hi = tool.attribute("id").as_int(); 
    } 

루프가 도구를 실행 = tool.next_sibling를 (" 적 ") 끝까지 도달하고 루프 밖으로 점프합니다. 첫 번째 적으로부터 정보를 얻을 수 있기 때문에 나는 옳은 일을하고 있습니다.

답변

0

나는 무엇을했는지 모른다. 하지만 지금은 효과가있는 것 같습니다. 이것은 정말로 이상하다, 나는 클래스에 일을 바꾸지 않았고 지금은 효과가있다.

어쨌든 모두 좋습니다!

관련 문제