Skip to main content

SetXml

Sets the XML content of the current XML node.

Syntax

expression.SetXml(strXml);

expression - A variable that represents a ApiCustomXmlNode class.

Parameters

NameRequired/OptionalData typeDefaultDescription
strXmlRequiredstringThe XML string to set as the node content.

Returns

boolean

Example

This example shows how to get the XPath of a custom XML node.

let doc = Api.GetDocument();
let xmlManager = doc.GetCustomXmlParts();
let xmlText = `
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book>
<title lang="en">The Odyssey</title>
<author>Homer</author>
<year>-740</year>
<price>30.00</price>
</book>
</bookstore>`;
let xml = xmlManager.Add(xmlText);
let node = xml.GetNodes('/bookstore/book')[0];
node.SetXml("<book>Updated content</book>");
let paragraph = Api.CreateParagraph();
paragraph.AddText(xml.GetXml());
doc.AddElement(0, paragraph);