irrXML help please?

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
grizzlebee
Posts: 2
Joined: Thu Dec 15, 2005 8:31 pm

irrXML help please?

Post by grizzlebee »

Hi, I have an XML file that looks like this:
<Environment>
<Viewport Color="0,128,192" Fov="0" NearClip="-0.000000" FarClip="0.000000" />
</Environment>

How do I get the pointer to child node? I have this so far syntax but it seems not to work:( Thank u.

while(xml && xml->read()) {
If (xml->GetNodeName()=="Environment") {
If (xml->GetNodeName()=="Viewport") {
std::string EnvColor = xml->getAttributeValue("Color");
std::string EnvFov = xml->getAttributeValue("Fov");
std::string EnvNearClip = xml->getAttributeValue("NearClip");
std::string EnvFarClip = xml->getAttributeValue("FarClip");
}
}
}
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post by pfo »

What you want to do is this:

Code: Select all

while (xml && xml->read())
{
core::stringw element = xml->getNodeName();
switch (xml->getNodeType())
{
case io::EXN_ELEMENT:
if (element == L"Environment")
;// there are no data items for environment
if (element == L"Viewport")
{
core::stringw color = xml->getAttributeValue(L"Color");
float FOV = xml->getAttributeValueAsFloat();
// etc....
}
}
Only 1 node can be the active node at a time. For your <environment> </environment> tags, you could set a boolean environment variable to true if you need to, but since they contain no data items you might as well ignore them.
grizzlebee
Posts: 2
Joined: Thu Dec 15, 2005 8:31 pm

Post by grizzlebee »

Ah i see. Thanks It worked great. :P
Post Reply