Main Content

matlab.io.xml.dom.NamedNodeMap Class

Namespace: matlab.io.xml.dom

Set of document nodes with names

Since R2021a

Description

A matlab.io.xml.dom.NamedNodeMap object contains a set of nodes that have names. These methods return a NamedNodeMap object:

The matlab.io.xml.dom.NamedNodeMap class is a handle class.

Class Attributes

ConstructOnLoad
true
HandleCompatible
true

For information on class attributes, see Class Attributes.

Properties

expand all

Number of items in the list, specified as a double.

Attributes:

GetAccess
public
SetAccess
immutable
Transient
true
NonCopyable
true

Methods

expand all

Examples

collapse all

This example finds and displays the names and values of the attributes of an element.

Read an XML string into a matlab.io.xml.dom.Document object.

import matlab.io.xml.dom.*
doc = parseString(Parser,'<para Bold="on" Color="red">Hello</para>');

Get the elements named para.

paralist = getElementsByTagName(doc,'para');
m = getLength(paralist)-1;
s = '';

For every para element, get the attribute names and values and save them in the character vector s.

for i = 0:m
    para = item(paralist,i);
    attrlist = getAttributes(para);
    n = getLength(attrlist)-1;
    for j=0:n
        attr = item(attrlist,j);
        s = [s sprintf('%s = %s\n',getNodeName(attr),getNodeValue(attr))];
    end
end

Display the attribute names and values stored in s.

disp(s);
Bold = on
Color = red

Version History

Introduced in R2021a