Xmlreader: getNodeData and getNodeName return same value?

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
OnyxIdol
Posts: 10
Joined: Sat Jun 14, 2008 9:06 pm
Location: Germany

Xmlreader: getNodeData and getNodeName return same value?

Post by OnyxIdol »

Ok, So I'm trying to use IXmlreader. But, whenever I call getNodeData() or getNodeName(), the result is always the same value.

I tried to use IXMLReaderUTF8 instead, same result. I also tried changing the encoding of my XML-file from ANSI to UTF8 to UNICODE to no advance.

If I am not mistaking, the getNodeData() Method should return everything that is inside the element, that is, entire subnodes and such.

What Am I doing wrong?
Image

Code: Select all

IXMLReaderUTF8 *reader=files->createXMLReaderUTF8("../debug/Units2.xml");

	stringw MessageText;
	while(reader&&reader->read())
	{		
		stringw nodeName=reader->getNodeName();
		stringw nodeData=reader->getNodeData();
	}
	reader->drop();

Code: Select all

<data>
  <object id="drone" type="unitTemplate">
    <primary id="drone_body"/>
    <assets>
      <!--A plain skinned node-->
      <asset id="drone_head" attach="head"/>
      <!--A weapon-->
      <asset id="minigun_left" attach="gun_left"/>
      <asset id="minigun_right" attach="gun_right"/>
    </assets>
    <specifics>
      <unitStats hp="500" speed="0,1" />
    </specifics>
  </object>
</data>
ldrrn
Posts: 4
Joined: Sun Jul 20, 2008 9:14 am

Post by ldrrn »

I'm having similar problem. I got my irrlicht from svn (revision 1420).

I have tried

Code: Select all

irr::io::IrrXMLReader* xml = irr::io::createIrrXMLReader("config.xml");
and

Code: Select all

irr::io::IXMLReaderUTF8 *xml = filesystem->createXMLReaderUTF8("config.xml");
both methods gave me same results, that was getNodeName() == getNodeData().

I have also checked CXMLReaderImpl.h, the implementations of getNodeName() and getNodeData() are the same

Code: Select all

	//! Returns the name of the current node.
	virtual const char_type* getNodeName() const
	{
		return NodeName.c_str();
	}


	//! Returns data of the current node.
	virtual const char_type* getNodeData() const
	{
		return NodeName.c_str();
	}
i believe there was nothing wrong in irrlicht engine, since the irr mesh example works fine, but may be the irrxml example was wrong or missing some steps?
ldrrn
Posts: 4
Joined: Sun Jul 20, 2008 9:14 am

Post by ldrrn »

ok, i'd found the solution myself. indeed there's nothing wrong with irrxml.

i believe irrxml see a xml statement in this way

Code: Select all

<AAA>BBB</AAA>
AAA, BBB and /AAA are considered as different node types.

therefore,
AAA -> io::EXN_ELEMENT, xml->getNodeName() == "AAA"
BBB -> io::EXN_TEXT, xml->getNodeName() == "BBB", xml->getNodeData() == "BBB"
/BBB -> io::EXN_ELEMENT_END, xml->getNodeName() == "AAA"
Post Reply