主题
添加子元素 - XmlAppendChild
函数简介
向元素末尾添加子元素。
接口名称
XmlAppendChildDLL调用
c
int32_t XmlAppendChild(int64_t parent, int64_t child, int32_t* err);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| parent | 长整数型 | 父元素句柄。 |
| child | 长整数型 | 子元素句柄。 |
| err | 整数型 | 错误码输出参数,可为NULL。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int64_t doc = ola.XmlCreateDocument();
if (doc != 0) {
int32_t err = 0;
int64_t root = ola.XmlCreateElement(doc, "root", &err);
ola.XmlInsertRootElement(doc, root, &err);
int64_t user = ola.XmlCreateElement(doc, "user", &err);
ola.XmlAppendChild(root, user, &err);
ola.XmlFree(doc);
}csharp
using OLAPlug;
var ola = new OLAPlugServer();
long doc = ola.XmlCreateDocument();
if (doc != 0)
{
int err;
long root = ola.XmlCreateElement(doc, "root", out err);
ola.XmlInsertRootElement(doc, root, out err);
long user = ola.XmlCreateElement(doc, "user", out err);
ola.XmlAppendChild(root, user, out err);
ola.XmlFree(doc);
}python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
doc = ola.XmlCreateDocument()
if doc != 0:
root, _ = ola.XmlCreateElement(doc, "root")
ola.XmlInsertRootElement(doc, root)
user, _ = ola.XmlCreateElement(doc, "user")
ola.XmlAppendChild(root, user)
ola.XmlFree(doc)java
import com.olaplug.OLAPlugServer;
import com.sun.jna.ptr.IntByReference;
OLAPlugServer ola = new OLAPlugServer();
long doc = ola.XmlCreateDocument();
if (doc != 0) { ola.XmlFree(doc); }cpp
var ola = com("OlaPlug.OlaSoft")
var doc = ola.XmlCreateDocument()
if(doc) { ola.XmlFree(doc) }vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
doc = ola.XmlCreateDocument()
If doc <> 0 Then ola.XmlFree(doc)
End Iftext
.局部变量 ola, OLAPlug
ola.创建 ()
doc = ola.XmlCreateDocument ()
.如果真 (doc ≠ 0)
ola.XmlFree (doc)
.如果真结束aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var doc = ola.XmlCreateDocument();
if(doc){ ola.XmlFree(doc); }text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 doc = ola.XmlCreateDocument()
如果真 (doc ≠ 0) { ola.XmlFree(doc) }cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int64_t doc = ola.XmlCreateDocument();
if (doc != 0) { ola.XmlFree(doc); }原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
long doc = XmlCreateDocument(instance);
if (doc != 0) {
int err = 0;
long root = XmlCreateElement(instance, doc, "root", &err);
XmlInsertRootElement(instance, doc, root, &err);
XmlFree(instance, doc);
}csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
long instance = CreateCOLAPlugInterFace();
long doc = XmlCreateDocument(instance);
if (doc != 0) {
int err = 0;
long root = XmlCreateElement(instance, doc, "root", err);
XmlInsertRootElement(instance, doc, root, err);
XmlFree(instance, doc);
}python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
doc = ola.XmlCreateDocument(instance)
if doc:
err = c_int(0)
root = ola.XmlCreateElement(instance, doc, b"root", err)
ola.XmlInsertRootElement(instance, doc, root, err)
ola.XmlFree(instance, doc)返回值
| 返回值 | 说明 |
|---|---|
0 | 成功。 |
| 其他 | 错误码,失败。 |
注意事项
| 项目 | 说明 |
|---|---|
| 子元素会被添加到父元素的末尾 | 子元素会被添加到父元素的末尾。 |
| 一个元素可以有多个子元素 | 一个元素可以有多个子元素。 |
