ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > irrXML
forum topic indicator getNodeName the same as getNodeData?
person icon
xDan
Guest
Quote
2007-07-27 23:31:38

Hi,

Consider this: "<highscore>You got a new high score!</highscore>"

Why is getNodeName always the same as getNodeData? That is, for that example line I get 3 nodes: "highscore", "You got a new high score!" and "highscore" (the closing tag).

Shouldn't it just give one node? With getNodeName as "highscore" and getNodeData as "You got a new high score!"? Because the contents are really associated with the container tag names...

I tried to hack around this by saving the last EXN_ELEMENT name, then on each EXN_TEXT I can do:

case EXN_TEXT:
  if (lastElement == "highscore") highScoreText = xml->getNodeData();

But the problem with this is empty lines (not inside tags) and whitespace seem to appear as nodes. So often after setting "highScoreText" to the correct value, lastElement will not have changed by the times some whitespace appears, and "highScoreText" will be set incorrectly to this whitespace.

Thanks

person icon
niko
Moderator
Quote
2007-07-29 20:57:52

getNodeData is used for text nodes and getNodeName for element nodes. Because getNodeData() would not make sense for elements and getNodeNames not for text nodes, instead of returning an error, this is returned. But if you say empty lines not inside tags appear as nodes, than this is a bug, but I've never discovered this one. Could you post a file as examlpe?

person icon
xDan
Registered User
Quote
2007-07-31 13:44:52

I should have mentioned I am using the version of irrxml with irrlicht 1.3.

With this XML (saved with wordpad as unicode text document)
<?xml version="1.0" encoding="UTF-16"?>
<language>

<translation lang="english">

     <!-- Game over text -->
     
     <highscore>New High Score!!</highscore>
     <nohighscore>Game Over!! You scored</nohighscore>

     <points>Beautiful points</points>
     <points>Delightful points</points>
     <points>Shiny points</points>
     <points>Marvellous points</points>
     <points>Delectable points</points>

     <highscore2>you beat the previous score of %1 points :)</highscore2>
     <nohighscore2>but you didn't beat the high score of %1 points :(</nohighscore2>

</translation>

</language>


And using this code:

        while (xml->read())
        {
            wprintf(L"Node contents: [%s]\n", xml->getNodeName());
         }


I get this output:
Node contents: []
Node contents: [language]
Node contents: [

]
Node contents: [translation]
Node contents: [

     ]
Node contents: [ Game over text ]
Node contents: [
     
     ]
Node contents: [highscore]
Node contents: [New High Score!!]
Node contents: [highscore]
Node contents: [
     ]
Node contents: [nohighscore]
Node contents: [Game Over!! You scored]
Node contents: [nohighscore]
Node contents: [

     ]
Node contents: [points]
Node contents: [Beautiful points]
Node contents: [points]
Node contents: [
     ]
Node contents: [points]
Node contents: [Delightful points]
Node contents: [points]
Node contents: [
     ]
Node contents: [points]
Node contents: [Shiny points]
Node contents: [points]
Node contents: [
     ]
Node contents: [points]
Node contents: [Marvellous points]
Node contents: [points]
Node contents: [
     ]
Node contents: [points]
Node contents: [Delectable points]
Node contents: [points]
Node contents: [

     ]
Node contents: [highscore2]
Node contents: [you beat the previous score of %1 points :)]
Node contents: [highscore2]
Node contents: [
     ]
Node contents: [nohighscore2]
Node contents: [but you didn't beat the high score of %1 points :(]
Node contents: [nohighscore2]
Node contents: [

]
Node contents: [translation]
Node contents: [

]
Node contents: [language]


Thanks! I'm getting around this by not using the node if it starts with '13'. So if it is a bug it's not urgent.

person icon
bobby
Guest
Quote
2008-04-06 15:47:30

AnAJTW Hi! Nice site! Where is a add to favorite button& ;)


Create reply:










 

  

Possible 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


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






Copyright© Ambiera e.U. all rights reserved.
Contact | Imprint | Products | Privacy Policy | Terms and Conditions |