iterating NodeList::iterator gives "Text" nodes



Hello. I have this code and it generate some xml like this:

<?xml version="1.0" encoding="UTF-8"?>
<Scenario>
  <A/>
  <B/>
  <C/>
</Scenario>

When i want to obtain all the childs Elements (A, B, C) i use a list in this way

xmlpp::Node::NodeList list = rootNode->get_children();

for (xmlpp::Node::NodeList::iterator cur = list.begin(); cur != list.end(); ++cur)
{
cout<<(*cur)->get_name()<<endl;
}

when i obtain the list:
text
A
text
B
text
C
text

Why has it TextNodes interleaved with the Nodes i want ?



I dont understand very well the inheritance hierarchy of node types (https://developer.gnome.org/libxml++/stable/classxmlpp_1_1Node.html):

  • xmlpp::Node:
    • xmlpp::Attribute
    • xmlpp::ContentNode
      • xmlpp::CdataNode
      • xmlpp::CommentNode
      • xmlpp::ProcessingInstructionNode
      • xmlpp::TextNode
    • xmlpp::Element
    • xmlpp::EntityReference

    is there some documentation that explains better inheritance hierarchy of node types and when is used each?

    Thank you very much for your time !!!

Attachment: main.cc
Description: Binary data



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]