跳到主要内容

GetElement

通过元素在文档中的位置返回元素。

语法

expression.GetElement(nPos);

expression - 表示 ApiDocument 类的变量。

参数

名称必需/可选数据类型默认值描述
nPos必需number将从文档中获取的元素位置。

返回值

DocumentElement

示例

此示例展示如何通过元素在文档内容中的位置获取元素。

// How to get element knowing its index.

// Get the first paragraph and add text to it.

let doc = Api.GetDocument();
let section = doc.GetFinalSection();
let docContent = section.GetHeader("default", true);
let paragraph = docContent.GetElement(0);
paragraph.AddText("This is the text in the default header");