Aspose::Words::Markup::IStructuredDocumentTag::RemoveSelfOnly method

IStructuredDocumentTag::RemoveSelfOnly method

Removes just this SDT node itself, but keeps the content of it inside the document tree.

virtual void Aspose::Words::Markup::IStructuredDocumentTag::RemoveSelfOnly()=0

Examples

Shows how to remove structured document tag, but keeps content inside.

auto doc = System::MakeObject<Aspose::Words::Document>(get_MyDir() + u"Structured document tags.docx");

// This collection provides a unified interface for accessing ranged and non-ranged structured tags.
System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<Aspose::Words::Markup::IStructuredDocumentTag>>> sdts = doc->get_Range()->get_StructuredDocumentTags()->LINQ_ToList();
ASSERT_EQ(5, sdts->LINQ_Count());

// Here we can get child nodes from the common interface of ranged and non-ranged structured tags.
for (auto&& sdt : System::IterateOver(sdts))
{
    if (sdt->GetChildNodes(Aspose::Words::NodeType::Any, false)->get_Count() > 0)
    {
        sdt->RemoveSelfOnly();
    }
}

sdts = doc->get_Range()->get_StructuredDocumentTags()->LINQ_ToList();
ASSERT_EQ(0, sdts->LINQ_Count());

See Also