跳到主要内容

GetNodeValue

返回当前节点内容的 XML 字符串表示。

语法

expression.GetNodeValue();

expression - 表示 ApiCustomXmlNode 类的变量。

参数

此方法没有任何参数。

返回值

string

示例

读取电子表格中特定 XML 节点的存储值。

// How do I retrieve what value is saved inside an XML node in a spreadsheet?

// Extract a node's raw value to inspect embedded data in a spreadsheet.

const worksheet = Api.GetActiveSheet();
const xmlManager = worksheet.GetCustomXmlParts();
const xmlString = `
<zoo>
<animal species='Lion'>
<name>Leo</name>
<age>5</age>
</animal>
</zoo>`;
const xml = xmlManager.Add(xmlString);

const animalNode = xml.GetNodes('/zoo/animal')[0];
const nodeValue = animalNode.GetNodeValue();
worksheet.GetRange('A1').SetValue('Node value: ' + nodeValue);