跳到主要内容

GetCount

Returns a number of custom XML parts in the XML manager.

Syntax

expression.GetCount();

expression - A variable that represents a ApiCustomXmlParts class.

Parameters

This method doesn't have any parameters.

Returns

number

Example

This example shows how to get the count of custom XML parts in the XML manager.

// How to get the count of custom XML parts.

// Get the count of XML parts.

let presentation = Api.GetPresentation();
let xmlManager = presentation.GetCustomXmlParts();
xmlManager.Add("<products><item><name>Laptop</name><price>999</price></item></products>");
xmlManager.Add("<user><name>John Doe</name><email>john@example.com</email></user>");
let count = xmlManager.GetCount();
let slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();
let fill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61));
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let shape = Api.CreateShape("rect", 300 * 36000, 130 * 36000, fill, stroke);
shape.SetPosition(608400, 1267200);
let docContent = shape.GetDocContent();
let paragraph = docContent.GetElement(0);
let run = Api.CreateRun();
run.SetFontSize(60);
run.AddText("There are " + count + " custom XML parts in the presentation.");
paragraph.AddElement(run);
slide.AddObject(shape);