CustomXmlSchemaCollectionItem Property

Gets or sets the element at the specified index.

Namespace:  Aspose.Words.Markup
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public string this[
	int index
] { get; set; }

Parameters

index
Type: SystemInt32

Property Value

Type: String
Examples
Shows how to work with an XML schema collection.
// Create a document and add a custom XML part
Document doc = new Document();

string xmlPartId = Guid.NewGuid().ToString("B");
string xmlPartContent = "<root><text>Hello, World!</text></root>";
CustomXmlPart xmlPart = doc.CustomXmlParts.Add(xmlPartId, xmlPartContent);

// Once the part is created, we can add XML schema associations like this,
// and perform other collection-related operations on the list of schemas for this part
xmlPart.Schemas.Add("http://www.w3.org/2001/XMLSchema");

// Collections can be cloned and elements can be added
CustomXmlSchemaCollection schemas = xmlPart.Schemas.Clone();
schemas.Add("http://www.w3.org/2001/XMLSchema-instance");
schemas.Add("http://schemas.microsoft.com/office/2006/metadata/contentType");

Assert.AreEqual(3, schemas.Count);
Assert.AreEqual(2, schemas.IndexOf(("http://schemas.microsoft.com/office/2006/metadata/contentType")));

// We can iterate over the collection with an enumerator
using (IEnumerator<string> enumerator = schemas.GetEnumerator())
{
    while (enumerator.MoveNext())
    {
        Console.WriteLine(enumerator.Current);
    }
}

// We can also remove elements by index, element, or we can clear the entire collection
schemas.RemoveAt(2);
schemas.Remove("http://www.w3.org/2001/XMLSchema");
schemas.Clear();

Assert.AreEqual(0, schemas.Count);
See Also