跳到主要内容

GetXml

返回当前节点的 XML 字符串。

语法

expression.GetXml();

expression - 表示 ApiCustomXmlNode 类的变量。

参数

此方法没有任何参数。

返回值

string

示例

此示例演示如何获取自定义 XML 节点的 XML 字符串表示。

// How to retrieve XML string representation from custom XML node elements.

// Get XML string from book node.

let worksheet = Api.GetActiveSheet();
let xmlManager = worksheet.GetCustomXmlParts();
let xml = xmlManager.Add("<book><title>JavaScript Guide</title><author>John Smith</author></book>");
let bookNode = xml.GetNodes('/book')[0];
let xmlString = bookNode.GetXml();
worksheet.GetRange("A1").SetValue("XML content:");
worksheet.GetRange("A2").SetValue(xmlString);