using boost::property_tree, is it possible to create a xml attribute with a '.' in the name?

StackOverflow https://stackoverflow.com/questions/21608445

  •  08-10-2022
  •  | 
  •  

문제

I'm using boost 1.51 and have something like this:

boost::property_tree::ptree some_tree;
some_tree.put("hello.world.<xmlattr>.foo.bar","4711");

I was hoping to get

<hello>
  <world foo.bar="4711"/>
</hello>

But I only get

<hello>
  <world foo=""/>
</hello>

Using boost::property_tree, is it possible to create an xml file with an attribute name containing a '.' character or do I need to look elsewhere?

도움이 되었습니까?

해결책

You have to use a separator other than the default .. Try this,

boost::property_tree::ptree some_tree;
some_tree.put(ptree::path("hello/world/<xmlattr>/foo.bar", '/'),"4711");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top