Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

OfficeCustomXmlPartCollection<T>.RemoveAt(Int32) Method

Removes a custom XML part at the specified index from the collection.

Namespace: DevExpress.Office

Assembly: DevExpress.Office.v24.2.Core.dll

NuGet Package: DevExpress.Office.Core

#Declaration

void RemoveAt(
    int index
)

#Parameters

Name Type Description
index Int32

A zero-based index of the custom XML part to be removed. It should be non-negative and less than the number of elements in the collection.

#Remarks

Use the Clear method to remove all items from CustomXmlPartCollection associated with a text document or workbook.

The example below shows how to remove custom XML parts from a DOCX file.

using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer())
{
    Document document = wordProcessor.Document;
    document.AppendText("This document contains custom XML parts.");

    // Add the first custom XML part.
    string xmlString1 = @"<?xml version=""1.0"" encoding=""UTF-8""?>
                            <Employees>
                                <FirstName>Stephen</FirstName>
                                <LastName>Edwards</LastName>
                            </Employees>";
    var xmlItem1 = document.CustomXmlParts.Add(xmlString1);

    // Add the second custom XML part.
    string xmlString2 = @"<?xml version=""1.0"" encoding=""UTF-8""?>
                            <Employees>
                                <FirstName>Andrew</FirstName>
                                <LastName>Fuller</LastName>
                            </Employees>";
    var xmlItem2 = document.CustomXmlParts.Add(xmlString2);

    // Remove the first item from the collection.
    document.CustomXmlParts.Remove(xmlItem1);
    // Use the RemoveAt method to remove an item at the specified position from the collection.
    // document.CustomXmlParts.RemoveAt(0);
    // Use the Clear method to remove all items from the collection.
    // document.CustomXmlParts.Clear();
}
See Also