Skip to content

Commit

Permalink
Add support for XML content in nodes
Browse files Browse the repository at this point in the history
Only the XML content that appears as first child of a node is
considered.
If the XML content appears after the first child (no counting
comments), it is ignored.

The XML content is added to the NodeConfig structure under the
`xml_content` field.
  • Loading branch information
Gaël Écorchard committed Nov 1, 2023
1 parent bcc7fd4 commit fd760d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/behaviortree_cpp/tree_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ struct NodeConfig
PortsRemapping input_ports;
// output ports
PortsRemapping output_ports;
// Node content (in the XML sense).
std::string xml_content;

const TreeNodeManifest* manifest = nullptr;

Expand Down
7 changes: 7 additions & 0 deletions src/xml_parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,13 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
}
}

// Get the XML content of the node.
const char* xml_content = element->GetText();
if (xml_content != nullptr)
{
config.xml_content = xml_content;
}

new_node = factory.instantiateTreeNode(instance_name, type_ID, config);
}

Expand Down

0 comments on commit fd760d3

Please sign in to comment.