如何从 XSD cxx 树对象编写 XML 文件
How to write an XML file from an XSD cxx tree object?
我正在使用一个库,该库使用 XSD 从基于 XML 的C++格式创建对象。
基本上,继承图看起来像这样:
class BaseClass: public xsd::cxx::tree::type;
class MainXmlObject: public BaseClass;
我想我需要将我的MainXmlObject
转换为xerces::DOMDocument
,然后使用DOMWriter
来编写实际的 XML 文件,但到目前为止我找不到正确的例程。
最好的方法是什么?
似乎将 --add-serialization
标志添加到 xsd 代码生成中,然后使用类似的东西:
xml_schema::namespace_infomap map;
// map[""].name = "test"; // xmlns
// map[""].schema = "http://sbgn.org/libsbgn/0.2"; // xsi:noNamespaceSchemaLocation
ofstream ofs(fname.c_str());
sbgn_(ofs, s, map); // invoking the stream here
ofs.close();
工程。参考:从 XSD 指南中添加序列化和详细信息。
相关文章:
- C++RapidXml-使用first_node()遍历以修改XML文件中节点的值
- c++ 读取 xml 文件的内容
- 删除 XML 文件中的子节点C++
- 在Cmake构建CmakeList.txt中读取/解析XML文件
- 使用 libxml2 解析 XML 文件时缺少元素值
- 为什么TinyXML2的XMLDocument::FirstChild()函数在尝试解析这个有效的XML文件时返回NULL?
- 如何循环 n 次,在 xml 文件中每个循环一个级别
- 无法从 XML 文件中获取值
- 如何让用户在 tinyxml2 中输入 XML 文件的路径
- 使用 TinyXML2 读取 C++ 中的 XML 文件
- OPENCV - 如何在OpenCV中使用Haar Cascade Github xml文件?
- 我们如何重新制作程序以打开xml文件并在价格单词之后读取百分比值并更改此值
- 如何使用QXmlStreamReader解析包含对其他XML文件的引用的XML文件
- 如何解析列存储格式的XML文件
- OpenCV - 打开一个从C++到Python的XML文件
- 修改 XML 文件 QXMLStreamReader/Writer
- 如何使用libcurl c ++从url保存XML文件
- C++/RapidXML:编辑节点并写入新的 XML 文件没有更新的节点
- 如何使用所有其他文件信息来编译代码,例如HAAR级联训练的权重的XML文件
- 是否可以将信息从XML文件转换为CPP