I'm trying to read an XML file with the structure
<name>search_name</name>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-25.0,30.0,0 -26.0,30.4,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
The coordinate string is variable length with each tuple separated by a space. Pugixml correctly finds the node tags in the larger file, but when getting the coordinate text, it will only read the first value.
Snippet of how it is being loaded/parsed:
pugi::xml_document doc;
pugi::xml_parse_result result = doc.load_file("file.xml");
pugi::xpath_node_set name_nodes = doc.select_nodes("//name");
for(const auto& xpath_node : name_nodes)
{
auto name_node = xpath_node.node();
if(name_node.text().as_string() == "search_name"))
{
auto path_node = name_node.parent().select_node("//coordinates");
if(path_node)
{
// Prints "-25.0,30.0,0"
std::cout << "Coordinate string: " << path_node.node().text().as_string() << std::endl;
}
}
}
Is this a limitation of pugixml, or is there a different way it can be parsed to preserve whitespace? I need to get the entire coordinate string as a string.