Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用谷物保存/加载 XML 文件,但无法弄清楚如何保存/加载 XML 属性。例如:
我有一个 XML 文件:
<windows height="101", width = "200"/>
和一个结构
struct window { int height; int width; }
如何定义序列化函数以使用谷物加载/保存 XML 属性值?
谷物不是通用的 XML 解析器。谷物随附的 XML 存档期望以它自己生成的 XML 格式读取,或者至少以与其期望格式相同的 XML 格式读取。
对于您的示例,谷物将作为输入:
<?xml version="1.0" encoding="utf-8"?> <cereal> <windows> <height>101</height> <width>200</width> </windows> </cereal>
要获得所需的行为,您需要修改 XML 存档或创建自己的存档。