Code: Select all
IXMLReader* xmlr = device->getFileSystem()->createXMLReader("./bahn3.xml");
while(xmlr && xmlr->read())
{
int c = -1;
//const wchar_t* nodename = xmlr->getNodeName();
wchar_t nodename[255];
swprintf(nodename,L"");
swprintf(nodename,xmlr->getNodeName());
printf("nodename1:%s\n",nodename);
if (core::stringw("Entities") == nodename)
{
c = xmlr->getAttributeValueAsInt(L"count");
printf("%i\n",c);
}
else
{
for(int i=0;i<c;i++)
{
IEntity Ent;
for(int j=0;j<2;j++)
{
wchar_t EntName[255];
swprintf(EntName,L"Entity%i-%i",i,j);
if (EntName == nodename)
{
printf("Testin mark#1");
if(j==0) //read partI of the current entity
{
Ent.X = xmlr->getAttributeValueAsFloat(L"posX");
Ent.Y = xmlr->getAttributeValueAsFloat(L"posY");
Ent.Z = xmlr->getAttributeValueAsFloat(L"posZ");
Ent.Box.offX = xmlr->getAttributeValueAsFloat(L"offX");
Ent.Box.offZ = xmlr->getAttributeValueAsFloat(L"offZ");
printf("%d %d",Ent.X,Ent.Y);
}
else if(j==1)
{
Ent.Box.length = xmlr->getAttributeValueAsFloat(L"length");
Ent.Box.width = xmlr->getAttributeValueAsFloat(L"width");
Ent.Box.height = xmlr->getAttributeValueAsFloat(L"height");
Ent.TYPE = xmlr->getAttributeValueAsInt(L"type");
}
} //end EntName
} //end FOR j
}//end FOR i
} //end if
printf("nodename:%s\n",nodename);
}
Code: Select all
nodename1:
nodename:
nodename1:E
2
nodename:E
nodename1:E
nodename:E
nodename1:E
nodename:E
nodename1:E
nodename:E
nodename1:E
nodename:E
nodename1:x
nodename:x
Code: Select all
<?xml version="1.0"?>
<Entities count="2" />
<Entity0-0 posX="0" posY="0" posZ="0" offX="-10" offZ="-10" />
<Entity0-1 length="0" width="0" height="0" type="0" />
<Entity1-0 posX="0" posY="0" posZ="0" offX="-10" offZ="-10" />
<Entity1-1 length="50" width="20" height="80" type="1" />
</xml>