SetNodeValue
Sets the XML content for the current node.
Syntax
expression.SetNodeValue(xml);
expression - A variable that represents a ApiCustomXmlNode class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| xml | Required | string | The XML string to set as the content of the current node. |
Returns
boolean
Example
This example shows how to set the XML content for the current node.
- Code
- Result
const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();
const xmlManager = presentation.GetCustomXmlParts();
const xmlText = '<bookstore><book><title lang="en">The Odyssey</title><author>Homer</author></book></bookstore>';
const xml = xmlManager.Add(xmlText);
const node = xml.GetNodes('/bookstore/book')[0];
node.SetNodeValue('<book><title lang="en">JavaScript Guide</title></book>');
const fill = Api.CreateSolidFill(Api.HexColor('#BF0000'));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = Api.CreateShape('rect', Api.MillimetersToEmus(300), Api.MillimetersToEmus(130), fill, stroke);
shape.SetPosition(Api.MillimetersToEmus(20), Api.MillimetersToEmus(35));
slide.AddObject(shape);
const docContent = shape.GetContent();
const paragraph = docContent.GetElement(0);
paragraph.AddText('XML after update: ' + xml.GetXml());