GXml.Object.clean_property_elements – GXml-0.20 – Vala Binding Reference

GXml.Object.clean_property_elements – GXml-0.20 Reference Manual

# clean_property_elements

## Description:

public virtual void clean_property_elements (string name) throws Error

Utility method to remove all instances of a property being child elements of object. Is useful if you have a GXml.Element property, it should be just one child of this type and you want to overwrite it.

In this example you have defined an element MyClass to be child of MyParentClass, but it should have just one element, once you set child_elements it calls clean_property_elements using property's canonicals name.

     public class MyClass : GXml.Element {
       public string name { get; set; }
     }
     public class MyParentClass : GXml.Element {
       private Myclass _child_elements = null;
       public MyClass child_elements {
         get { return _child_elements; }
         set {
           try {
             clean_property_elements ("child-elements");
             _child_elements = value;
             append_child (_child_elements);
           } catch (GLib.Error e) {
             warning (e.message);
           }
         }
       }
     }

## Parameters:

name | property name to search value type, use canonical names.

## Exceptions:

DomError | if property is not a GXml.Element.