Add-Ons & Services

XML iterator

Please post support and help requests here.

XML iterator

Postby vonkanaitor » 12 Jun 2013, 19:53

im trying to develop a scene loader for my directx project. My code as is below is very similar to one of the example slides. However, i have to nodes with the same name (<actor>) but the 2nd (which has different values) returns the info of the first one. What am i doing wrong?

Code: Select all
Poco::XML::NodeIterator it(_pDocument, Poco::XML::NodeFilter::SHOW_ELEMENT);

   Poco::XML::Node* pNode = it.nextNode();
   it.nextNode(); //I dont want to include my root element, is there another way of doing this?

   while (pNode)
      std::cout<<pNode->nodeName()<<" :"<< pNode->nodeValue() << "\n";

      if (pNode->nodeName() == "name")
         std::cout << "Loading Map with Name : " << getString(pNode->nodeName()) << "\n";

      if (pNode->nodeName() == "actor")
         std::cout << "Actor Type : " << getString("actor[@type]") << "Actor Name : " << getString("actor[@name]") << "\n";

           pNode = it.nextNode();

My xml looks like this:

Code: Select all

<actor type="1Volume" name="m_pActor1" enabled="true">
<attribute name="Rotation" value="-1.0 1.0 0.0"/>
<attribute name="Position" value="-1.2 0.0 0.0"/>

<actor type="2Volume" name="m_pActor2" enabled="false">
<attribute name="Rotation" value="1.0 1.0 0.0"/>
<attribute name="Position" value="1.2 0.0 0.0"/>

Posts: 4
Joined: 11 Dec 2012, 20:00

Return to Support

Who is online

Users browsing this forum: beetie and 5 guests