YXml.YXmlElement()

An YXmlElement imitates the behavior of a Dom Element.

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

new YXmlElement()

Methods

delete(index, lengthopt)

Deletes elements starting from an index.

Parameters:
Name Type Attributes Default Description
index number

Index at which to start deleting elements

length number <optional>
1

The number of elements to remove. Defaults to 1.

getAttribute(attributeName) → {String}

Returns an attribute value that belongs to the attribute name.

Parameters:
Name Type Description
attributeName String

The attribute name that identifies the queried value.

Returns:
String -

The queried attribute value.

getAttributes(snapshotopt) → {Object}

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

Parameters:
Name Type Attributes Description
snapshot Snapshot <optional>
Returns:
Object -

A JSON Object that describes the attributes.

insert(index, content)

Inserts new content at an index.

Parameters:
Name Type Description
index number

The index to insert content at

content Array.<(YXmlElement|YXmlText)>

The array of content

Example
// Insert character 'a' at position 0
 xml.insert(0, [new Y.XmlText('text')])

removeAttribute(attributeName)

Removes an attribute from this YXmlElement.

Parameters:
Name Type Description
attributeName String

The attribute name that is to be removed.

setAttribute(attributeName, attributeValue)

Sets or updates an attribute.

Parameters:
Name Type Description
attributeName String

The attribute name that is to be set.

attributeValue String

The attribute value that is to be set.

toDom(_documentopt, hooksopt, bindingopt) → {Node}

Creates a Dom Element that mirrors this YXmlElement.

Parameters:
Name Type Attributes Default Description
_document Document <optional>
document

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

hooks Object.<string, any> <optional>
{}

Optional property to customize how hooks are presented in the DOM

binding any <optional>

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

Returns:
Node -

The Dom Element

toDomString() → {String}

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

Returns:
String -

The string representation of this type.