跳到主要内容

GetXml

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

语法

expression.GetXml();

expression - 表示 ApiCustomXmlPart 类的变量。

参数

此方法没有任何参数。

返回值

string

示例

获取文档中自定义 XML 部件的 XML 字符串表示。

// How to get the xml for a custom XML part in a document?

// Get the xml and display the result 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);