ambiera home ambiera home

Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name:  Password:    
Ambiera Forum > irrXML
Problem parsing string and values
Author Text

Quillraven
Guest
Quote
2009-06-11 17:11:02

Hi,

i've a problem with my xml parser when i want to add text to parse and not only intvalues.

here is my xml file:


<?xml version="1.0"?>
<config>
<!--This is a config file for the Irrlicht Engine Mesh Viewer.-->
<data>
<WindowWidth width='1024'/>
<WindowHeight height='768'/>
<Fullscreen fullscreen='0'/>
</data>
<messageText starttext="Please select your preferred driver
(a) D3D 9.0c
(b) D3D 8.1
(c) OpenGL 1.5
other key to exit"
</messageText>
</config>


my code for loading the values correctly:

while( xml && xml->read() )
{
if (!strcmp("messageText", xml->getNodeName()))
starttext = xml->getAttributeValue("starttext");
else if ( !strcmp( "WindowWidth", xml->getNodeName() ) )
params.WindowSize.Width = xml->getAttributeValueAsInt( "width" );
else if ( !strcmp( "WindowHeight", xml->getNodeName() ) )
params.WindowSize.Height = xml->getAttributeValueAsInt( "height" );
else if ( !strcmp( "Fullscreen", xml->getNodeName() ) )
params.Fullscreen = xml->getAttributeValueAsInt( "fullscreen" );
}



and here the code "like in the tutorial". but this doesn't work neither with the text nor the values.

while( xml && xml->read() )
{
switch(xml->getNodeType())
{
case io::EXN_ELEMENT:
if (!strcmp("messageText", xml->getNodeName()))
starttext = xml->getAttributeValue("starttext");
break;

default:
if ( !strcmp( "WindowWidth", xml->getNodeName() ) )
params.WindowSize.Width = xml->getAttributeValueAsInt( "width" );
else if ( !strcmp( "WindowHeight", xml->getNodeName() ) )
params.WindowSize.Height = xml->getAttributeValueAsInt( "height" );
else if ( !strcmp( "Fullscreen", xml->getNodeName() ) )
params.Fullscreen = xml->getAttributeValueAsInt( "fullscreen" );
break;
}
}


can someone help me?


niko
Moderator
Quote
2009-06-12 12:56:28

Your xml file is invalid. The opening message text tag is never closed.


Quillraven
Guest
Quote
2009-06-16 17:55:41

i already managed it btw (i didn't have any knowledge with xml files ) but when i look in the tutorial xml file


<?xml version="1.0"?>
<config>
<!-- This is a config file for the mesh viewer -->
<model file="dwarf.dea" />
<messageText caption="Irrlicht Engine Mesh Viewer">
Welcome to the Mesh Viewer of the &quot;Irrlicht Engine&quot;.
</messageText>
</config>


it seems to be as the author did the same thing with the messagetext like me?

my file now looks like this and works for fine for me.
thx for help


<?xml version="1.0"?>
<config>
<!--Text when starting the game for choosing videodriver-->
<StartText text='Please select your preferred driver
(a) D3D 9.0c
(b) D3D 8.1
(c) OpenGL 1.5
other key to exit'/>

<!--Text when starting the game for choosing realtime shadows-->
<ShadowText text='Press "y" if you want to use realtime shadows'/>

<!--Configvalues of the game: graphics, sounds, etc-->
<data>
<WindowWidth width='1024'/>
<WindowHeight height='768'/>
<Fullscreen fullscreen='0'/>
<Sound sound='0'/>
</data>
</config>



Create reply:


Posted by: (you are not logged in)


Please enter the missing letter in: "Internat?onal" (you are not logged in)


Text:

 

  

Forum Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   





Software: Ambiera Light Forum. © 2008-2013 Nikolaus Gebhardt, Ambiera e.U.