设置布尔属性 - XmlSetAttributeBool
函数简介
设置元素的布尔类型属性。
接口名称
XmlSetAttributeBool
DLL调用
int32_t XmlSetAttributeBool(int64_t element, const char* name, int32_t value, int32_t* err)
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| element | int64_t | 元素句柄 |
| name | string | 属性名称 |
| value | int32_t | 布尔值(0表示false,非0表示true) |
| err | int32_t* | 错误码输出参数,可为NULL |
示例
int32_t err = 0;
int64_t doc = XmlCreateDocument();
int64_t root = XmlCreateElement(doc, "config", &err);
XmlInsertRootElement(doc, root, &err);
XmlSetAttributeBool(root, "enabled", 1, &err);
XmlSetAttributeBool(root, "debug", 0, &err);
XmlFree(doc);
返回值
| 返回值 | 说明 |
|---|---|
| 0 | 成功 |
| 其他 | 错误码 |
注意事项
- 布尔值会被转换为"true"或"false"字符串存储
- 如果属性已存在,会被覆盖
