跳到主要内容

GetByNamespace

根据命名空间从 XML 管理器返回自定义 XML 部件。

语法

expression.GetByNamespace(namespace);

expression - 表示 ApiCustomXmlParts 类的变量。

参数

名称必需/可选数据类型默认值描述
namespace必需stringXML 部件的命名空间。

返回值

ApiCustomXmlPart[]

示例

此示例演示如何根据命名空间检索自定义 XML 部件。

let doc = Api.GetDocument();
let xmlManager = doc.GetCustomXmlParts();
let xmlText = "<content xmlns='http://example.com'><text>Example XML</text></content>";
let xml = xmlManager.Add(xmlText);
let namespace = "http://example.com";
let xmlParts = xmlManager.GetByNamespace(namespace);
let infoParagraph = Api.CreateParagraph();
xmlParts.forEach(part => {
infoParagraph.AddText("XML part: " + part.GetXml());
});
doc.Push(infoParagraph);