跳到主要内容

Add

为当前 XML 节点创建子节点。

语法

expression.Add(nodeName);

expression - 表示 ApiCustomXmlNode 类的变量。

参数

名称必需/可选数据类型默认值描述
nodeName必需string新子节点的名称。

返回值

ApiCustomXmlNode

示例

此示例演示如何创建新子节点并将其作为当前 XML 节点的子节点插入。

let doc = Api.GetDocument();
let xmlManager = doc.GetCustomXmlParts();
let xml = xmlManager.Add("<content xmlns='http://example'><text>Hello World!</text></content>");
let rootNode = xml.GetNodes("/content")[0];
let textNode = rootNode.Add("text");
let classType = textNode.GetClassType();
let infoParagraph = Api.CreateParagraph();
infoParagraph.AddText("Class type: " + classType);
doc.Push(infoParagraph);