    import YXmlElement from 'yjs/src/Types/YXml/YXmlElement.js'

public class | source

# YXmlElement

#### Extends:

src/Types/YXml/YXml.js~YXmlFragment → YXmlElement

An YXmlElement imitates the behavior of a {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}.

- An YXmlElement has attributes (key value pairs)
- An YXmlElement has childElements that must inherit from YXmlElement

## Constructor Summary

Public Constructor
public | constructor () |

## Member Summary

Public Members
public | nodeName : * |

## Method Summary

Public Methods
public | getAttribute (attributeName: String): String Returns an attribute value that belongs to the attribute name. |
public | getAttributes (): Object Returns all attribute name/value pairs in a JSON Object. |
public | removeAttribute (attributeName: String): * Removes an attribute from this YXmlElement. |
public | setAttribute (attributeName: String, attributeValue: String): * Sets or updates an attribute. |
public | toDom (_document: Document, hooks: Object<key:hookDefinition>, binding: DomBinding): Element Creates a Dom Element that mirrors this YXmlElement. |
public | toString (): String Returns the string representation of this YXmlElement. |

## Public Constructors

### public constructor() source

## Public Members

### public nodeName: * source

## Public Methods

### public getAttribute(attributeName: String): String source

Returns an attribute value that belongs to the attribute name.

#### Params:

Name | Type | Attribute | Description
attributeName | String |  | The attribute name that identifies the queried value.

#### Return:

String | The queried attribute value.

### public getAttributes(): Object source

Returns all attribute name/value pairs in a JSON Object.

#### Return:

Object | A JSON Object that describes the attributes.

### public removeAttribute(attributeName: String): * source

Removes an attribute from this YXmlElement.

#### Params:

Name | Type | Attribute | Description
attributeName | String |  | The attribute name that is to be removed.

#### Return:

*

### public setAttribute(attributeName: String, attributeValue: String): * source

Sets or updates an attribute.

#### Params:

Name | Type | Attribute | Description
attributeName | String |  | The attribute name that is to be set.
attributeValue | String |  | The attribute value that is to be set.

#### Return:

*

### public toDom(_document: Document, hooks: Object<key:hookDefinition>, binding: DomBinding): Element source

Creates a Dom Element that mirrors this YXmlElement.

#### Params:

Name | Type | Attribute | Description

_document

Document

- optional
- default: document

The document object (you must define this when calling this method in nodejs)

hooks

Object<key:hookDefinition>

- optional
- default: {}

Optional property to customize how hooks are presented in the DOM

binding

DomBinding

- optional

You should not set this property. This is used if DomBinding wants to create a association to the created DOM type.

#### Return:

Element | The {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}

### public toString(): String source

Returns the string representation of this YXmlElement. The attributes are ordered by attribute-name, so you can easily use this method to compare YXmlElements

#### Return:

String | The string representation of this type.