Reading value from XML file

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
dawasw
Posts: 357
Joined: Tue Aug 10, 2004 4:39 pm
Location: Poland

Reading value from XML file

Post by dawasw »

Welcome friends... i have a little problem with getting a value to my in-game integer.

I use this :

Code: Select all

if (core::stringw("Mana") == xmlReader->getNodeName())
	{SavedPlayerMana = xmlReader->getAttributeValue(L"manavalue2");}
for getting a number value from xml file (it looks like this:
<Mana manavalue2="2000" />

After reading my .xml file i want to convert value to in-game integer:

Code: Select all

 int receiveSavedMana;
receiveSavedMana= atoi(SavedPlayerMana.c_str());
playermana = receiveSavedMana;
(where playermana above is an integer of course)

At the end of read xml function i have xmlReader->drop();

But when i use this in game , unfortunately my Mana drops from (start 100) to 0 ;/ (and it should get 2000 value)

I'm also using my 'read xml' function when playing game (not at the start)

Can you help me what i'm doing wrong ?
puh
Posts: 356
Joined: Tue Aug 26, 2003 3:53 pm

Post by puh »

getAttributeValueAsInt
dawasw
Posts: 357
Joined: Tue Aug 10, 2004 4:39 pm
Location: Poland

Post by dawasw »

I've tried that but it doesnt work either.
I'm still getting bad value.
VeneX
Posts: 228
Joined: Sun Nov 30, 2003 3:32 pm
Location: The Netherlands
Contact:

Post by VeneX »

Code: Select all

while(xml && xml->read()) 
{   nodeName = xml->getNodeName();
     ENodeType = xml->getNodeType();
     if(nodeName == "Mana") 
     {    receiveSavedMana = xml->getAttributeValueAsInt(L"manavalue2");            
     }
}
xml->drop();
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
Post Reply