跳到主要内容

GetXml

从自定义 XML 部件检索 XML 字符串。

语法

expression.GetXml();

expression - 表示 ApiCustomXmlPart 类的变量。

参数

此方法没有任何参数。

返回值

string

示例

将文档中自定义 XML 部件的完整 XML 内容作为字符串读取。

// How do I export or inspect the raw XML of a custom XML part in a document?

// Serialize the entire XML structure to display or process its contents in a document.

let doc = Api.GetDocument();
let xmlManager = doc.GetCustomXmlParts();
let xmlText = `
<?xml version="1.0" encoding="UTF-8"?>
<documentData xmlns="http://example.com/example">
<text attribute1="attribute1 value">node text</text>
</documentData>`;
let xml = xmlManager.Add(xmlText);
let xmlString = xml.GetXml();

let paragraph = Api.CreateParagraph();
paragraph.AddText("XML string representation: " + xmlString);
doc.Push(paragraph);