I'm trying to parse an XML file using the boost/propert_tree library. I can get the xml file correctly and everything, but when I look for childs, it doesn't find any.
I have an input.xml file:
<ax:hello someatribute:ax="dwadawfesfjsefs">
<something>523523</something>
<ax:whatever>
<ax:service_tree>
<ax:service>some</ax:service>
<ax:url>someulr</ax:url>
</ax:service_tree>
</ax:whatever>
</ax:hello>
The function where I try to parse the xml:
void parseXml(std::istream &stream)
{
using boost::property_tree::ptree;
ptree pt;
read_xml(stream, pt);
BOOST_FOREACH(ptree::value_type const &value, pt.get_child("ax:hello"))
{
std::cout << value.first;
}
}
And the main function:
int main()
{
std::ifstream stream("input.xml");
parseXml(stream);
return 0;
}
The error message I get is:
terminate called after throwing an instance of 'boost::exception_detail::clone_impl >' what(): No such node (ax:hello) Aborted (core dumped)`
As you can see, the ax:hello
tag is properly opened and closed, so it should be able to find it despite the attributes, right?
Hope someone knows what's going on in here!