Platforms to show: All Mac Windows Linux Cross-Platform

Back to XMLElementMBS class.

XMLElementMBS.AttributeNode(Name as String) as XMLAttributeMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Retrieves an XMLAttributeMBS node by name.

name: The name (nodeName) of the attribute to retrieve.

The XMLAttributeMBS node with the specified name (nodeName) or null if there is no such attribute.

XMLElementMBS.AttributeNodeNS(namespaceURI as string, localName as String) as XMLAttributeMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Retrieves an XMLAttributeMBS node by local name and namespace URI.

namespaceURI: The namespace URI of the attribute to retrieve.
localName: The local name of the attribute to retrieve.

The XMLAttributeMBS node with the specified attribute local name and namespace URI or nil if there is no such attribute.

XMLElementMBS.AttributeValue(Name as String) as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
property XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Retrieves an attribute value by name.
Example

Dim doc As New XMLDocumentMBS
Dim node As XMLElementMBS = doc.createElement("Hello")

node.AttributeValue("Hello") = "World"
node.AttributeValue("Value") = "123"
node.AttributeValue("Test") = "Value"

Dim attrs() As XMLAttributeMBS = node.AttributeNodes
For Each a As XMLAttributeMBS In attrs
MessageBox a.Name+": "+a.Value
Next

name: The name of the attribute to retrieve.
The XMLAttributeMBS value as a string, or the empty string if that attribute does not have a specified or default value.

If assigned, adds/sets a new attribute.
If an attribute with that name is already present in the element, its value is changed to be that of the value parameter. This value is a simple string, it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an XMLAttributeMBS node plus any XMLTextMBS and XMLEntityReferenceMBS nodes, build the appropriate subtree, and use setAttributeNode to assign it as the value of an attribute.
(Read and Write computed property)

XMLElementMBS.AttributeValueNS(namespaceURI as string, localName as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
property XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Retrieves an attribute value by local name and namespace URI.

namespaceURI The namespace URI of the attribute to retrieve.
localName The local name of the attribute to retrieve.

Returns the XMLAttributeMBS value as a string, or an "" if that attribute does not have a specified or default value.

Adds a new attribute when assigned.
If an attribute with the same local name and namespace URI is already present on the element, its prefix is changed to be the prefix part of the qualifiedName, and its value is changed to be the value parameter. This value is a simple string, it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an XMLAttributeMBS node plus any XMLTextMBS and XMLEntityReferenceMBS nodes, build the appropriate subtree, and use setAttributeNodeNS or setAttributeNode to assign it as the value of an attribute.

namespaceURI: The namespace URI of the attribute to create or alter.
qualifiedName: The qualified name of the attribute to create or alter.
value: The value to set in string form.
(Read and Write computed property)

XMLElementMBS.Constructor   Private

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
The private constructor.

XMLElementMBS.Element(Index as Integer) as XMLElementMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Queries element with given index.

Returns nil if index is out of index.

Some examples using this method:

XMLElementMBS.ElementsByTagName(TagName as String) as XMLElementMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Returns a DOMNodeList of all descendant elements with a given tag name, in the order in which they would be encountered in a preorder traversal of the XMLElementMBS tree.

name: The name of the tag to match on. The special value "*" matches all tags.

A list of matching XMLElementMBS nodes.

XMLElementMBS.ElementsByTagNameNS(namespaceURI as string, localName as String) as XMLElementMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Returns a nodes of all the DOMElements with a given local name and namespace URI in the order in which they would be encountered in a preorder traversal of the XMLDocumentMBS tree, starting from this node.

namespaceURI: The namespace URI of the elements to match on. The special value "*" matches all namespaces.
localName: The local name of the elements to match on. The special value "*" matches all local names.

XMLElementMBS.HasAttribute(Name as String) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Whether an attribute exists.

Returns true when an attribute with a given name is specified on this element or has a default value, false otherwise.

name: The name of the attribute to look for.

Returns true if an attribute with the given name is specified on this element or has a default value, false otherwise.

XMLElementMBS.HasAttributeNS(namespaceURI as string, localName as String) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Whether an attribute exists.

Returns true when an attribute with a given local name and namespace URI is specified on this element or has a default value, false otherwise.

namespaceURI: The namespace URI of the attribute to look for.
localName: The local name of the attribute to look for.
true: if an attribute with the given local name and namespace URI is specified or has a default value on this element, false otherwise.

XMLElementMBS.IterateElements as XMLIterateElementsMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Iterates over the elements.
Example

Dim doc As New XMLDocumentMBS("<doc><other>abc</other><test>def</test></doc>")

Dim root As XMLElementMBS = doc.DocumentElement
For Each e As XMLElementMBS In root.IterateElements
MessageBox e.toString
Next

For use with For Each Loops in Xojo.

Some examples using this method:

XMLElementMBS.IterateElementsByTagName(TagName as String) as XMLIterateElementsMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Iterates over the elements with matching tag name.
Example

Dim doc As New XMLDocumentMBS("<doc><test id=""1"">abc</test><test id=""2"">def</test></doc>")

Dim root As XMLElementMBS = doc.DocumentElement
For Each e As XMLElementMBS In root.IterateElementsByTagName("test")
MessageBox e.toString
Next

For use with For Each Loops in Xojo.

XMLElementMBS.IterateElementsByTagNameNS(namespaceURI as string, localName as String) as XMLIterateElementsMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Iterates over the elements with matching tag name.

For use with For Each Loops in Xojo.

XMLElementMBS.RemoveAttribute(Name as String)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Removes an attribute by name.
Example

Dim xml As String = "<test>test</test>"
Dim doc As New XMLDocumentMBS(xml)
Dim DocumentElement As XMLElementMBS = doc.DocumentElement

DocumentElement.AttributeValue("a") = "123"

MessageBox DocumentElement.toString

DocumentElement.RemoveAttribute("a")

MessageBox DocumentElement.toString

If the removed attribute is known to have a default value, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable.

To remove an attribute by local name and namespace URI, use the removeAttributeNS method.

XMLElementMBS.RemoveAttributeNode(Node as XMLAttributeMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Removes the specified attribute node.

If the removed XMLAttributeMBS has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix, when applicable.

XMLElementMBS.RemoveAttributeNS(namespaceURI as string, localName as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Removes an attribute by local name and namespace URI.

If the removed attribute has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix.

namespaceURI: The namespace URI of the attribute to remove.
localName: The local name of the attribute to remove.

XMLElementMBS.SetAttributeNode(AttributeNode as XMLAttributeMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Adds a new attribute.

If an attribute with that name (nodeName) is already present in the element, it is replaced by the new one.
AttributeNode: The XMLAttributeMBS node to add to the attribute list.
If the AttributeNode attribute replaces an existing attribute, the replaced XMLAttributeMBS node is returned, otherwise null is returned.

If the new attribute is from another document, we clone it first.

XMLElementMBS.SetAttributeNodeNS(AttributeNode as XMLAttributeMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Adds a new attribute.

If an attribute with that local name and namespace URI is already present in the element, it is replaced by the new one.

AttributeNode: The XMLAttributeMBS node to add to the attribute list.
If the newAttr attribute replaces an existing attribute with the same local name and namespace URI, the replaced XMLAttributeMBS node is returned, otherwise nil is returned.

If the new attribute is from another document, we clone it first.

XMLElementMBS.SetIdAttribute(name as string, isID as boolean)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sets ID attribute.

If the parameter isId is true, this method declares the specified attribute to be a user-determined ID attribute. This affects the value of XMLAttributeMBS::isId and the behavior of ElementById in XMLDocumentMBS, but does not change any schema that may be in use, in particular this does not affect the SchemaTypeInfo XMLAttributeMBS of the specified XMLAttributeMBS node. Use the value false for the parameter isId to undeclare an attribute for being a user-determined ID attribute. To specify an XMLAttributeMBS by local name and namespace URI, use the setIdAttributeNS method.

name: The name of the XMLAttributeMBS.
isId: Whether the attribute is of type ID.

XMLElementMBS.SetIdAttributeNode(idAttr as XMLAttributeMBS, isID as boolean)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sets the id attribute node.

If the parameter isId is true, this method declares the specified attribute to be a user-determined ID attribute. This affects the value of isId of XMLAttributeMBS and the behavior of getElementById of XMLDocumentMBS, but does not change any schema that may be in use, in particular this does not affect the SchemaTypeInfo of XMLAttributeMBS of the specified XMLAttributeMBS node. Use the value false for the parameter isId to undeclare an attribute for being a user-determined ID attribute.

idAttr: The XMLAttributeMBS node.
isId: Whether the attribute is of type ID.

If the new attribute is from another document, we clone it first.

XMLElementMBS.SetIdAttributeNS(namespaceURI as string, localName as string, isID as boolean)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sets id attribute.

If the parameter isId is true, this method declares the specified attribute to be a user-determined ID attribute. This affects the value of isId of XMLAttributeMBS and the behavior of getElementById of XMLDocumentMBS, but does not change any schema that may be in use, in particular this does not affect the getSchemaTypeInfo of XMLAttributeMBS of the specified XMLAttributeMBS node. Use the value false for the parameter isId to undeclare an attribute for being a user-determined ID attribute.

namespaceURI: The namespace URI of the XMLAttributeMBS.
localName: The local name of the XMLAttributeMBS.
isId: Whether the attribute is of type ID.

The items on this page are in the following plugins: MBS XML Plugin.


The biggest plugin in space...