跳到主要内容

Add

向 XML 管理器添加新的自定义 XML 部件。

语法​

expression.Add(xml);

expression - 表示 ApiCustomXmlParts 类的变量。

参数​

名称必需/可选数据类型默认值描述
xml必需string要添加的 XML 字符串。

返回值​

ApiCustomXmlPart

示例​

向文档附加新的自定义 XML 部件。

// How do I add a custom XML part with specific content to a document?

// Embed structured XML data into a document to store metadata alongside the content in a document.

let doc = Api.GetDocument();
let xmlManager = doc.GetCustomXmlParts();
let newXml = xmlManager.Add("<content xmlns='http://example' version='1.0'></content>");
let infoParagraph = Api.CreateParagraph();
infoParagraph.AddText("New XML part added: " + newXml.GetXml());
doc.Push(infoParagraph);