Re: iterating NodeList::iterator gives "Text" nodes



thank you very much. Your answer is really useful for me.


2013/8/30 Kjell Ahlstedt <kjell ahlstedt bredband net>
The text nodes contain the white space between the tags. If you use
  document.write_to_file("file.txt");
instead of
  document.write_to_file_formatted("file.txt");
no white space is added, and there are no text nodes.

I don't think there is any documentation that explains the inheritance hierarchy. Actually I don't think there is much to explain. The inheritance hierarchy has no deeper meaning. It does not correspond to the structure of an xml document. I think it's mostly an attempt to group node types that have something in common.

Kjell

2013-08-29 21:00, Pablo Madoery skrev:
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 !!!





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