添加注释 - XmlAddComment
函数简介
创建注释节点并添加到元素。
接口名称
XmlAddComment
DLL调用
int32_t XmlAddComment(int64_t doc, int64_t element, const char* comment, int32_t* err)
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| doc | int64_t | XML文档句柄 |
| element | int64_t | 元素句柄 |
| comment | string | 注释内容 |
| err | int32_t* | 错误码输出参数,可为NULL |
示例
int32_t err = 0;
int64_t doc = XmlCreateDocument();
int64_t root = XmlCreateElement(doc, "config", &err);
XmlInsertRootElement(doc, root, &err);
// 添加注释
XmlAddComment(doc, root, "这是配置文件", &err);
int64_t server = XmlCreateElement(doc, "server", &err);
XmlAppendChild(root, server, &err);
XmlAddComment(doc, server, "服务器配置", &err);
XmlFree(doc);
返回值
| 返回值 | 说明 |
|---|---|
| 0 | 成功 |
| 其他 | 错误码 |
注意事项
- 注释内容不会被XML解析器处理
- 注释会出现在XML文档中
- 用于添加说明和文档
