Aspose::Words::Markup::CustomXmlPropertyCollection Class Reference

Detailed Description

Represents a collection of custom XML attributes or smart tag properties.

Items are CustomXmlProperty objects.

Examples

Shows how to work with smart tag properties to get in depth information about smart tags.

auto doc = MakeObject<Document>(MyDir + u"Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
ArrayPtr<SharedPtr<SmartTag>> smartTags = doc->GetChildNodes(NodeType::SmartTag, true)->LINQ_OfType<SharedPtr<SmartTag>>()->LINQ_ToArray();
ASSERT_EQ(8, smartTags->get_Length());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
SharedPtr<CustomXmlPropertyCollection> properties = smartTags[7]->get_Properties();
ASSERT_EQ(4, properties->get_Count());
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<CustomXmlProperty>>> enumerator = properties->GetEnumerator();
while (enumerator->MoveNext())
{
std::cout << "Property name: " << enumerator->get_Current()->get_Name() << ", value: " << enumerator->get_Current()->get_Value() << std::endl;
ASSERT_EQ(u"", enumerator->get_Current()->get_Uri());
}
}
// We can also access the properties in various ways, such as a key-value pair.
ASSERT_TRUE(properties->Contains(u"Day"));
ASSERT_EQ(u"22", properties->idx_get(u"Day")->get_Value());
ASSERT_EQ(u"2003", properties->idx_get(2)->get_Value());
ASSERT_EQ(1, properties->IndexOfKey(u"Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties->RemoveAt(3);
ASSERT_EQ(3, properties->get_Count());
// 2 - Remove by name:
properties->Remove(u"Year");
ASSERT_EQ(2, properties->get_Count());
// 3 - Clear the entire collection at once:
properties->Clear();
ASSERT_EQ(0, properties->get_Count());

#include <Aspose.Words.Cpp/Markup/CustomXmlPropertyCollection.h>

+ Inheritance diagram for Aspose::Words::Markup::CustomXmlPropertyCollection:

Public Member Functions

void Add (const SharedPtr< CustomXmlProperty > &property)
 Adds a property to the collection. More...
 
void Clear ()
 Removes all elements from the collection. More...
 
bool Contains (const String &name)
 Determines whether the collection contains a property with the given name. More...
 
int32_t get_Count ()
 Gets the number of elements contained in the collection. More...
 
SharedPtr< IEnumerator< SharedPtr< CustomXmlProperty > > > GetEnumerator () override
 Returns an enumerator object that can be used to iterate over all items in the collection. More...
 
virtual const TypeInfoGetType () const override
 
SharedPtr< CustomXmlPropertyidx_get (const String &name)
 Gets a property with the specified name. More...
 
SharedPtr< CustomXmlPropertyidx_get (int32_t index)
 Gets a property at the specified index. More...
 
int32_t IndexOfKey (const String &name)
 Returns the zero-based index of the specified property in the collection. More...
 
virtual bool Is (const TypeInfo &target) const override
 
void Remove (const String &name)
 Removes a property with the specified name from the collection. More...
 
void RemoveAt (int32_t index)
 Removes a property at the specified index. More...
 

Static Public Member Functions

static const TypeInfoType ()
 

Member Function Documentation

◆ Add()

void Aspose::Words::Markup::CustomXmlPropertyCollection::Add ( const System::SharedPtr< Aspose::Words::Markup::CustomXmlProperty > &  property)

Adds a property to the collection.

Parameters
propertyThe property to add.
Examples

Shows how to work with smart tag properties to get in depth information about smart tags.

auto doc = MakeObject<Document>(MyDir + u"Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
ArrayPtr<SharedPtr<SmartTag>> smartTags = doc->GetChildNodes(NodeType::SmartTag, true)->LINQ_OfType<SharedPtr<SmartTag>>()->LINQ_ToArray();
ASSERT_EQ(8, smartTags->get_Length());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
SharedPtr<CustomXmlPropertyCollection> properties = smartTags[7]->get_Properties();
ASSERT_EQ(4, properties->get_Count());
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<CustomXmlProperty>>> enumerator = properties->GetEnumerator();
while (enumerator->MoveNext())
{
std::cout << "Property name: " << enumerator->get_Current()->get_Name() << ", value: " << enumerator->get_Current()->get_Value() << std::endl;
ASSERT_EQ(u"", enumerator->get_Current()->get_Uri());
}
}
// We can also access the properties in various ways, such as a key-value pair.
ASSERT_TRUE(properties->Contains(u"Day"));
ASSERT_EQ(u"22", properties->idx_get(u"Day")->get_Value());
ASSERT_EQ(u"2003", properties->idx_get(2)->get_Value());
ASSERT_EQ(1, properties->IndexOfKey(u"Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties->RemoveAt(3);
ASSERT_EQ(3, properties->get_Count());
// 2 - Remove by name:
properties->Remove(u"Year");
ASSERT_EQ(2, properties->get_Count());
// 3 - Clear the entire collection at once:
properties->Clear();
ASSERT_EQ(0, properties->get_Count());

◆ Clear()

void Aspose::Words::Markup::CustomXmlPropertyCollection::Clear ( )

Removes all elements from the collection.

Examples

Shows how to work with smart tag properties to get in depth information about smart tags.

auto doc = MakeObject<Document>(MyDir + u"Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
ArrayPtr<SharedPtr<SmartTag>> smartTags = doc->GetChildNodes(NodeType::SmartTag, true)->LINQ_OfType<SharedPtr<SmartTag>>()->LINQ_ToArray();
ASSERT_EQ(8, smartTags->get_Length());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
SharedPtr<CustomXmlPropertyCollection> properties = smartTags[7]->get_Properties();
ASSERT_EQ(4, properties->get_Count());
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<CustomXmlProperty>>> enumerator = properties->GetEnumerator();
while (enumerator->MoveNext())
{
std::cout << "Property name: " << enumerator->get_Current()->get_Name() << ", value: " << enumerator->get_Current()->get_Value() << std::endl;
ASSERT_EQ(u"", enumerator->get_Current()->get_Uri());
}
}
// We can also access the properties in various ways, such as a key-value pair.
ASSERT_TRUE(properties->Contains(u"Day"));
ASSERT_EQ(u"22", properties->idx_get(u"Day")->get_Value());
ASSERT_EQ(u"2003", properties->idx_get(2)->get_Value());
ASSERT_EQ(1, properties->IndexOfKey(u"Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties->RemoveAt(3);
ASSERT_EQ(3, properties->get_Count());
// 2 - Remove by name:
properties->Remove(u"Year");
ASSERT_EQ(2, properties->get_Count());
// 3 - Clear the entire collection at once:
properties->Clear();
ASSERT_EQ(0, properties->get_Count());

◆ Contains()

bool Aspose::Words::Markup::CustomXmlPropertyCollection::Contains ( const System::String name)

Determines whether the collection contains a property with the given name.

Parameters
nameCase-sensitive name of the property to locate.
Returns
True if the item is found in the collection; otherwise, false.
Examples

Shows how to work with smart tag properties to get in depth information about smart tags.

auto doc = MakeObject<Document>(MyDir + u"Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
ArrayPtr<SharedPtr<SmartTag>> smartTags = doc->GetChildNodes(NodeType::SmartTag, true)->LINQ_OfType<SharedPtr<SmartTag>>()->LINQ_ToArray();
ASSERT_EQ(8, smartTags->get_Length());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
SharedPtr<CustomXmlPropertyCollection> properties = smartTags[7]->get_Properties();
ASSERT_EQ(4, properties->get_Count());
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<CustomXmlProperty>>> enumerator = properties->GetEnumerator();
while (enumerator->MoveNext())
{
std::cout << "Property name: " << enumerator->get_Current()->get_Name() << ", value: " << enumerator->get_Current()->get_Value() << std::endl;
ASSERT_EQ(u"", enumerator->get_Current()->get_Uri());
}
}
// We can also access the properties in various ways, such as a key-value pair.
ASSERT_TRUE(properties->Contains(u"Day"));
ASSERT_EQ(u"22", properties->idx_get(u"Day")->get_Value());
ASSERT_EQ(u"2003", properties->idx_get(2)->get_Value());
ASSERT_EQ(1, properties->IndexOfKey(u"Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties->RemoveAt(3);
ASSERT_EQ(3, properties->get_Count());
// 2 - Remove by name:
properties->Remove(u"Year");
ASSERT_EQ(2, properties->get_Count());
// 3 - Clear the entire collection at once:
properties->Clear();
ASSERT_EQ(0, properties->get_Count());

◆ get_Count()

int32_t Aspose::Words::Markup::CustomXmlPropertyCollection::get_Count ( )

Gets the number of elements contained in the collection.

Examples

Shows how to work with smart tag properties to get in depth information about smart tags.

auto doc = MakeObject<Document>(MyDir + u"Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
ArrayPtr<SharedPtr<SmartTag>> smartTags = doc->GetChildNodes(NodeType::SmartTag, true)->LINQ_OfType<SharedPtr<SmartTag>>()->LINQ_ToArray();
ASSERT_EQ(8, smartTags->get_Length());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
SharedPtr<CustomXmlPropertyCollection> properties = smartTags[7]->get_Properties();
ASSERT_EQ(4, properties->get_Count());
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<CustomXmlProperty>>> enumerator = properties->GetEnumerator();
while (enumerator->MoveNext())
{
std::cout << "Property name: " << enumerator->get_Current()->get_Name() << ", value: " << enumerator->get_Current()->get_Value() << std::endl;
ASSERT_EQ(u"", enumerator->get_Current()->get_Uri());
}
}
// We can also access the properties in various ways, such as a key-value pair.
ASSERT_TRUE(properties->Contains(u"Day"));
ASSERT_EQ(u"22", properties->idx_get(u"Day")->get_Value());
ASSERT_EQ(u"2003", properties->idx_get(2)->get_Value());
ASSERT_EQ(1, properties->IndexOfKey(u"Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties->RemoveAt(3);
ASSERT_EQ(3, properties->get_Count());
// 2 - Remove by name:
properties->Remove(u"Year");
ASSERT_EQ(2, properties->get_Count());
// 3 - Clear the entire collection at once:
properties->Clear();
ASSERT_EQ(0, properties->get_Count());

◆ GetEnumerator()

System::SharedPtr< System::Collections::Generic::IEnumerator< System::SharedPtr< Aspose::Words::Markup::CustomXmlProperty > > > Aspose::Words::Markup::CustomXmlPropertyCollection::GetEnumerator ( )
override

Returns an enumerator object that can be used to iterate over all items in the collection.

Examples

Shows how to work with smart tag properties to get in depth information about smart tags.

auto doc = MakeObject<Document>(MyDir + u"Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
ArrayPtr<SharedPtr<SmartTag>> smartTags = doc->GetChildNodes(NodeType::SmartTag, true)->LINQ_OfType<SharedPtr<SmartTag>>()->LINQ_ToArray();
ASSERT_EQ(8, smartTags->get_Length());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
SharedPtr<CustomXmlPropertyCollection> properties = smartTags[7]->get_Properties();
ASSERT_EQ(4, properties->get_Count());
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<CustomXmlProperty>>> enumerator = properties->GetEnumerator();
while (enumerator->MoveNext())
{
std::cout << "Property name: " << enumerator->get_Current()->get_Name() << ", value: " << enumerator->get_Current()->get_Value() << std::endl;
ASSERT_EQ(u"", enumerator->get_Current()->get_Uri());
}
}
// We can also access the properties in various ways, such as a key-value pair.
ASSERT_TRUE(properties->Contains(u"Day"));
ASSERT_EQ(u"22", properties->idx_get(u"Day")->get_Value());
ASSERT_EQ(u"2003", properties->idx_get(2)->get_Value());
ASSERT_EQ(1, properties->IndexOfKey(u"Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties->RemoveAt(3);
ASSERT_EQ(3, properties->get_Count());
// 2 - Remove by name:
properties->Remove(u"Year");
ASSERT_EQ(2, properties->get_Count());
// 3 - Clear the entire collection at once:
properties->Clear();
ASSERT_EQ(0, properties->get_Count());

◆ GetType()

virtual const System::TypeInfo & Aspose::Words::Markup::CustomXmlPropertyCollection::GetType ( ) const
overridevirtual

Reimplemented from System::Object.

◆ idx_get() [1/2]

System::SharedPtr< Aspose::Words::Markup::CustomXmlProperty > Aspose::Words::Markup::CustomXmlPropertyCollection::idx_get ( const System::String name)

Gets a property with the specified name.

Parameters
nameCase-sensitive name of the property to locate.
Examples

Shows how to work with smart tag properties to get in depth information about smart tags.

auto doc = MakeObject<Document>(MyDir + u"Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
ArrayPtr<SharedPtr<SmartTag>> smartTags = doc->GetChildNodes(NodeType::SmartTag, true)->LINQ_OfType<SharedPtr<SmartTag>>()->LINQ_ToArray();
ASSERT_EQ(8, smartTags->get_Length());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
SharedPtr<CustomXmlPropertyCollection> properties = smartTags[7]->get_Properties();
ASSERT_EQ(4, properties->get_Count());
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<CustomXmlProperty>>> enumerator = properties->GetEnumerator();
while (enumerator->MoveNext())
{
std::cout << "Property name: " << enumerator->get_Current()->get_Name() << ", value: " << enumerator->get_Current()->get_Value() << std::endl;
ASSERT_EQ(u"", enumerator->get_Current()->get_Uri());
}
}
// We can also access the properties in various ways, such as a key-value pair.
ASSERT_TRUE(properties->Contains(u"Day"));
ASSERT_EQ(u"22", properties->idx_get(u"Day")->get_Value());
ASSERT_EQ(u"2003", properties->idx_get(2)->get_Value());
ASSERT_EQ(1, properties->IndexOfKey(u"Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties->RemoveAt(3);
ASSERT_EQ(3, properties->get_Count());
// 2 - Remove by name:
properties->Remove(u"Year");
ASSERT_EQ(2, properties->get_Count());
// 3 - Clear the entire collection at once:
properties->Clear();
ASSERT_EQ(0, properties->get_Count());

◆ idx_get() [2/2]

System::SharedPtr< Aspose::Words::Markup::CustomXmlProperty > Aspose::Words::Markup::CustomXmlPropertyCollection::idx_get ( int32_t  index)

Gets a property at the specified index.

Parameters
indexZero-based index of the property.
Examples

Shows how to work with smart tag properties to get in depth information about smart tags.

auto doc = MakeObject<Document>(MyDir + u"Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
ArrayPtr<SharedPtr<SmartTag>> smartTags = doc->GetChildNodes(NodeType::SmartTag, true)->LINQ_OfType<SharedPtr<SmartTag>>()->LINQ_ToArray();
ASSERT_EQ(8, smartTags->get_Length());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
SharedPtr<CustomXmlPropertyCollection> properties = smartTags[7]->get_Properties();
ASSERT_EQ(4, properties->get_Count());
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<CustomXmlProperty>>> enumerator = properties->GetEnumerator();
while (enumerator->MoveNext())
{
std::cout << "Property name: " << enumerator->get_Current()->get_Name() << ", value: " << enumerator->get_Current()->get_Value() << std::endl;
ASSERT_EQ(u"", enumerator->get_Current()->get_Uri());
}
}
// We can also access the properties in various ways, such as a key-value pair.
ASSERT_TRUE(properties->Contains(u"Day"));
ASSERT_EQ(u"22", properties->idx_get(u"Day")->get_Value());
ASSERT_EQ(u"2003", properties->idx_get(2)->get_Value());
ASSERT_EQ(1, properties->IndexOfKey(u"Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties->RemoveAt(3);
ASSERT_EQ(3, properties->get_Count());
// 2 - Remove by name:
properties->Remove(u"Year");
ASSERT_EQ(2, properties->get_Count());
// 3 - Clear the entire collection at once:
properties->Clear();
ASSERT_EQ(0, properties->get_Count());

◆ IndexOfKey()

int32_t Aspose::Words::Markup::CustomXmlPropertyCollection::IndexOfKey ( const System::String name)

Returns the zero-based index of the specified property in the collection.

Parameters
nameThe case-sensitive name of the property.
Returns
The zero based index. Negative value if not found.
Examples

Shows how to work with smart tag properties to get in depth information about smart tags.

auto doc = MakeObject<Document>(MyDir + u"Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
ArrayPtr<SharedPtr<SmartTag>> smartTags = doc->GetChildNodes(NodeType::SmartTag, true)->LINQ_OfType<SharedPtr<SmartTag>>()->LINQ_ToArray();
ASSERT_EQ(8, smartTags->get_Length());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
SharedPtr<CustomXmlPropertyCollection> properties = smartTags[7]->get_Properties();
ASSERT_EQ(4, properties->get_Count());
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<CustomXmlProperty>>> enumerator = properties->GetEnumerator();
while (enumerator->MoveNext())
{
std::cout << "Property name: " << enumerator->get_Current()->get_Name() << ", value: " << enumerator->get_Current()->get_Value() << std::endl;
ASSERT_EQ(u"", enumerator->get_Current()->get_Uri());
}
}
// We can also access the properties in various ways, such as a key-value pair.
ASSERT_TRUE(properties->Contains(u"Day"));
ASSERT_EQ(u"22", properties->idx_get(u"Day")->get_Value());
ASSERT_EQ(u"2003", properties->idx_get(2)->get_Value());
ASSERT_EQ(1, properties->IndexOfKey(u"Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties->RemoveAt(3);
ASSERT_EQ(3, properties->get_Count());
// 2 - Remove by name:
properties->Remove(u"Year");
ASSERT_EQ(2, properties->get_Count());
// 3 - Clear the entire collection at once:
properties->Clear();
ASSERT_EQ(0, properties->get_Count());

◆ Is()

virtual bool Aspose::Words::Markup::CustomXmlPropertyCollection::Is ( const System::TypeInfo target) const
overridevirtual

Reimplemented from System::Object.

◆ Remove()

void Aspose::Words::Markup::CustomXmlPropertyCollection::Remove ( const System::String name)

Removes a property with the specified name from the collection.

Parameters
nameThe case-sensitive name of the property.
Examples

Shows how to work with smart tag properties to get in depth information about smart tags.

auto doc = MakeObject<Document>(MyDir + u"Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
ArrayPtr<SharedPtr<SmartTag>> smartTags = doc->GetChildNodes(NodeType::SmartTag, true)->LINQ_OfType<SharedPtr<SmartTag>>()->LINQ_ToArray();
ASSERT_EQ(8, smartTags->get_Length());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
SharedPtr<CustomXmlPropertyCollection> properties = smartTags[7]->get_Properties();
ASSERT_EQ(4, properties->get_Count());
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<CustomXmlProperty>>> enumerator = properties->GetEnumerator();
while (enumerator->MoveNext())
{
std::cout << "Property name: " << enumerator->get_Current()->get_Name() << ", value: " << enumerator->get_Current()->get_Value() << std::endl;
ASSERT_EQ(u"", enumerator->get_Current()->get_Uri());
}
}
// We can also access the properties in various ways, such as a key-value pair.
ASSERT_TRUE(properties->Contains(u"Day"));
ASSERT_EQ(u"22", properties->idx_get(u"Day")->get_Value());
ASSERT_EQ(u"2003", properties->idx_get(2)->get_Value());
ASSERT_EQ(1, properties->IndexOfKey(u"Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties->RemoveAt(3);
ASSERT_EQ(3, properties->get_Count());
// 2 - Remove by name:
properties->Remove(u"Year");
ASSERT_EQ(2, properties->get_Count());
// 3 - Clear the entire collection at once:
properties->Clear();
ASSERT_EQ(0, properties->get_Count());

◆ RemoveAt()

void Aspose::Words::Markup::CustomXmlPropertyCollection::RemoveAt ( int32_t  index)

Removes a property at the specified index.

Parameters
indexThe zero based index.
Examples

Shows how to work with smart tag properties to get in depth information about smart tags.

auto doc = MakeObject<Document>(MyDir + u"Smart tags.doc");
// A smart tag appears in a document with Microsoft Word recognizes a part of its text as some form of data,
// such as a name, date, or address, and converts it to a hyperlink that displays a purple dotted underline.
// In Word 2003, we can enable smart tags via "Tools" -> "AutoCorrect options..." -> "SmartTags".
// In our input document, there are three objects that Microsoft Word registered as smart tags.
// Smart tags may be nested, so this collection contains more.
ArrayPtr<SharedPtr<SmartTag>> smartTags = doc->GetChildNodes(NodeType::SmartTag, true)->LINQ_OfType<SharedPtr<SmartTag>>()->LINQ_ToArray();
ASSERT_EQ(8, smartTags->get_Length());
// The "Properties" member of a smart tag contains its metadata, which will be different for each type of smart tag.
// The properties of a "date"-type smart tag contain its year, month, and day.
SharedPtr<CustomXmlPropertyCollection> properties = smartTags[7]->get_Properties();
ASSERT_EQ(4, properties->get_Count());
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<CustomXmlProperty>>> enumerator = properties->GetEnumerator();
while (enumerator->MoveNext())
{
std::cout << "Property name: " << enumerator->get_Current()->get_Name() << ", value: " << enumerator->get_Current()->get_Value() << std::endl;
ASSERT_EQ(u"", enumerator->get_Current()->get_Uri());
}
}
// We can also access the properties in various ways, such as a key-value pair.
ASSERT_TRUE(properties->Contains(u"Day"));
ASSERT_EQ(u"22", properties->idx_get(u"Day")->get_Value());
ASSERT_EQ(u"2003", properties->idx_get(2)->get_Value());
ASSERT_EQ(1, properties->IndexOfKey(u"Month"));
// Below are three ways of removing elements from the properties collection.
// 1 - Remove by index:
properties->RemoveAt(3);
ASSERT_EQ(3, properties->get_Count());
// 2 - Remove by name:
properties->Remove(u"Year");
ASSERT_EQ(2, properties->get_Count());
// 3 - Clear the entire collection at once:
properties->Clear();
ASSERT_EQ(0, properties->get_Count());

◆ Type()

static const System::TypeInfo & Aspose::Words::Markup::CustomXmlPropertyCollection::Type ( )
static