GXml.Element – GXml-0.20 – Vala Binding Reference

GXml.Element – GXml-0.20 Reference Manual

# Element

## Object Hierarchy:

## Description:

public class Element : Node, DomChildNode, DomNonDocumentTypeChildNode, DomParentNode, DomElement, Object

A DOM4 implementation of DomElement, for one-step-parsing.

This object avoids pre and post XML parsing, by using a one step parsing to translate text XML tree to an GObject based tree.

A GXml Object Model (GOM) implementation of GXml.Element. It can be used transparently as DomElement in a XML tree.

It also allows delayed parsing, so you can read large documents by parsing just a XML element node and its attributes but not its children; save its children as a text, for a post-on-step-parsing.

All known sub-classes:

- HtmlElement
- XsdAnnotation
- XsdAttribute
- XsdAttributeGroup
- XsdBaseAttribute
- XsdBaseContent
- XsdBaseType
- XsdComplexContent
- XsdComplexType
- XsdElement
- XsdExtension
- XsdOpenContent

- XsdSchema
- XsdSimpleContent
- XsdSimpleType
- XsdTypeDefinition
- XsdTypeList
- XsdTypeRestriction
- XsdTypeRestrictionAssertion
- XsdTypeRestrictionDef
- XsdTypeRestrictionEnumeration
- XsdTypeRestrictionExplicitTimezone
- XsdTypeRestrictionFractionDigits

- XsdTypeRestrictionLength
- XsdTypeRestrictionMaxExclusive
- XsdTypeRestrictionMaxInclusive
- XsdTypeRestrictionMaxLength
- XsdTypeRestrictionMinExclusive
- XsdTypeRestrictionMinInclusive
- XsdTypeRestrictionMinLength
- XsdTypeRestrictionPattern
- XsdTypeRestrictionTotalDigits
- XsdTypeRestrictionWhiteSpace
- XsdTypeUnion

Namespace: GXml
Package: GXml-0.20

## Content:

### Classes:

- Attributes - Holds attributes in current node, using attribute's name as key and it's value as value. Appends namespace prefix to attribute's name as key if is a namespaced attribute.

### Properties:

- public DomNamedNodeMap attributes { owned get; }
- public int child_element_count { get; }
- public DomHTMLCollection children { owned get; }
- public DomTokenList class_list { owned get; }
  A list of values of all attributes called 'class'.
- public string? class_name { owned get; set; }
  An attribute called 'class'.
- public DomElement? first_element_child { owned get; }
- public string? id { owned get; set; }
  An attribute called 'id'.
- public DomElement? last_element_child { owned get; }
- public string local_name { owned get; }
  Derived classes should define it at construction time, using GXml.Node._local_name field. This is the node's name.
- public string? namespace_uri { owned get; }
- public DomElement? next_element_sibling { owned get; }
- public bool parse_children { get; set; }
  If true all children are parsed. If false, all its children are stored as plain string in unparsed. In order to generate an XML tree use read_unparsed.
- public string? prefix { owned get; }
- public DomElement? previous_element_sibling { owned get; }
- public MemoryOutputStream read_buffer { get; set; }
  On memory GLib.MemoryOutputStream with the unparsed string of the element
- public string tag_name { owned get; }
- public string unparsed { get; set; }
  Temporally stores, all unparsed children as plain string. See parse_children.

### Creation methods:

- public Element ()

### Methods:

- public InputStream create_stream () throws Error
  Creates an GLib.InputStream to write a string representation in XML of GXml.Element using node's GXml.Document
- public async InputStream create_stream_async (Cancellable? cancellable = null) throws Error
  Creates an GLib.InputStream to write a string representation in XML of GXml.Element using node's GXml.Document
- public string? get_attribute (string name)
- public string? get_attribute_ns (string? namespace_uri, string local_name)
- public DomHTMLCollection get_elements_by_class_name (string class_names)
- public DomHTMLCollection get_elements_by_tag_name (string local_name)
- public DomHTMLCollection get_elements_by_tag_name_ns (string? @namespace, string local_name)
- public bool has_attribute (string name)
- public bool has_attribute_ns (string? namespace_uri, string local_name)
- public void initialize (string local_name)
  Convenient function to initialize, at construction time, a GXml.Element using given local name. If GXml.Element.initialize_with_namespace has been called in any base class, this method just change element node's name and keeps previous namespace and prefix.
- public void initialize_document (DomDocument doc, string local_name)
  Convenient function to initialize, at construction time, a GXml.Element using given local name and document.
- public void initialize_document_with_namespace (DomDocument doc, string? namespace_uri, string? prefix, string local_name)
  Convenient function to initialize, at construction time, a GXml.Element using given local name, document and namespace.
- public void initialize_with_namespace (string? namespace_uri, string? prefix, string local_name)
  Convenient function to initialize, at construction time, a GXml.Element using given local name and namespace.
- public string? lookup_namespace_uri (string? prefix)
- public string? lookup_prefix (string? nspace)
- public void parse_buffer () throws Error
  Synchronically parse read_buffer
- public async void parse_buffer_async () throws Error
  Asynchronically parse read_buffer
- public uint parse_pending ()
  Monitor multi-threading parsing
- public DomNodeList query_selector_all (string selectors) throws Error
- public void read_from_file (File f, Cancellable? cancellable = null) throws Error
  Parses an XML file, deserializing it over GXml.Element.
- public async void read_from_file_async (File f, Cancellable? cancellable = null) throws Error
  Parses asynchronically an XML file, deserializing it over GXml.Element.
- public void read_from_stream (InputStream istream, Cancellable? cancellable = null) throws Error
  Parses an XML over a GLib.InputStream , deserializing it over GXml.Element.
- public async void read_from_stream_async (InputStream istream, Cancellable? cancellable = null) throws Error
  Parses asynchronically an XML over a GLib.InputStream, deserializing it over GXml.Element.
- public void read_from_string (string str, Cancellable? cancellable = null) throws Error
  Parses an XML string, deserializing it over GXml.Element.
- public async void read_from_string_async (string str, Cancellable? cancellable = null) throws Error
  Parses an XML string, deserializing it over GXml.Element.
- public void read_unparsed () throws Error
  Parse all children, adding them to current node, stored in unparsed. Once it finish, sets unparsed to null.
- public void remove ()
- public void remove_attribute (string name)
- public void remove_attribute_ns (string? namespace_uri, string local_name)
- public void set_attribute (string name, string value) throws Error
- public void set_attribute_ns (string? namespace_uri, string name, string value) throws Error
- public void write_file (File f, Cancellable? cancellable = null) throws Error
  Uses element's GXml.Document to write an XML to a file, serializing it.
- public async void write_file_async (File f, Cancellable? cancellable = null) throws Error
  Uses element's GXml.Document to write asynchronically an XML to a file, serializing it.
- public void write_stream (OutputStream stream) throws Error
  Uses element's GXml.Document to write an XML to a stream, serializing it.
- public async void write_stream_async (OutputStream stream, Cancellable? cancellable = null) throws Error
  Uses element's GXml.Document to write an XML to a stream, serializing it.
- public string write_string (Cancellable? cancellable = null) throws Error
  Serialize GXml.Element to a string.
- public async string write_string_async (Cancellable? cancellable = null) throws Error
  Serialize asynchronically GXml.Element to a string.

### Fields:

- protected Attributes _attributes
  Reference to Attributes for element's attributes. Derived classes should avoid to modify it.
- protected string _namespace_uri
  Use this field to set node's namespace URI. Can used to set it at construction time.

### Inherited Members:

All known members inherited from class GXml.Node

- _base_uri
- _child_nodes
- _document
- _local_name
- _node_type
- _node_value
- _parent
- _prefix
- add_event_listener
- append_child
- base_uri
- child_nodes

- compare_document_position
- contains
- dispatch_event
- first_child
- has_child_nodes
- insert_before
- is_default_namespace
- is_equal_node
- last_child
- lookup_namespace_uri
- lookup_prefix
- next_sibling

- node_name
- node_type
- node_value
- normalize
- owner_document
- parent_element
- parent_node
- previous_sibling
- remove_child
- remove_event_listener
- replace_child
- text_content

All known members inherited from class GLib.Object

- @get
- @new
- @ref
- @set
- add_toggle_ref
- add_weak_pointer
- bind_property
- connect
- constructed
- disconnect
- dispose
- dup_data
- dup_qdata
- force_floating
- freeze_notify
- get_class
- get_data

- get_property
- get_qdata
- get_type
- getv
- interface_find_property
- interface_install_property
- interface_list_properties
- is_floating
- new_valist
- new_with_properties
- newv
- notify
- notify_property
- ref_count
- ref_sink
- remove_toggle_ref
- remove_weak_pointer

- replace_data
- replace_qdata
- set_data
- set_data_full
- set_property
- set_qdata
- set_qdata_full
- set_valist
- setv
- steal_data
- steal_qdata
- thaw_notify
- unref
- watch_closure
- weak_ref
- weak_unref

All known members inherited from interface GXml.DomChildNode

- remove

All known members inherited from interface GXml.DomNonDocumentTypeChildNode

- next_element_sibling

- previous_element_sibling

All known members inherited from interface GXml.DomParentNode

- child_element_count
- children
- first_element_child

- get_elements_by_property_value
- last_element_child

- query_selector
- query_selector_all

All known members inherited from interface GXml.DomElement

- attributes
- class_list
- class_name
- create_stream
- create_stream_async
- get_attribute
- get_attribute_ns
- get_elements_by_class_name
- get_elements_by_tag_name
- get_elements_by_tag_name_ns
- has_attribute
- has_attribute_ns

- id
- local_name
- matches
- namespace_uri
- prefix
- read_from_file
- read_from_file_async
- read_from_stream
- read_from_stream_async
- read_from_string
- read_from_string_async
- read_from_uri

- read_from_uri_async
- remove_attribute
- remove_attribute_ns
- set_attribute
- set_attribute_ns
- tag_name
- write_file
- write_file_async
- write_stream
- write_stream_async
- write_string
- write_string_async

All known members inherited from interface GXml.Object

- clean_property_elements
- find_elements
- find_object_property_name
- find_property
- find_property_name

- get_attribute
- get_child
- get_properties_list
- get_property_element_list

- get_property_string
- remove_attribute
- set_attribute
- set_instance_property

All known members inherited from interface GXml.DomEventTarget

- add_event_listener

- dispatch_event

- remove_event_listener

All known members inherited from interface GXml.DomNode

- append_child
- base_uri
- child_nodes
- compare_document_position
- contains
- copy
- first_child
- has_child_nodes
- insert_before

- is_default_namespace
- is_equal_node
- last_child
- lookup_namespace_uri
- lookup_prefix
- next_sibling
- node_name
- node_type
- node_value

- normalize
- owner_document
- parent_element
- parent_node
- previous_sibling
- remove_child
- replace_child
- text_content