跳到主要内容

Add

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

语法

expression.Add(nodeName);

expression - 表示 ApiCustomXmlNode 类的变量。

参数

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

返回值

ApiCustomXmlNode

示例

向文档中现有的自定义 XML 节点添加新的子节点。

// How do I insert a child node into a custom XML node in a document?

// Extend stored XML data by nesting a new element under an existing node in a document.

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);