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");
}
}
}
irrXML help please?
-
- Posts: 370
- Joined: Mon Aug 29, 2005 10:54 pm
- Location: http://web.utk.edu/~pfox1
What you want to do is this:
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.
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....
}
}