Main Content

matlab.io.xml.dom.NodeList Class

Namespace: matlab.io.xml.dom

List of document nodes

Since R2021a

Description

An object of the matlab.io.xml.dom.NodeList class contains a list of document nodes.

These methods return a NodeList object:

The matlab.io.xml.dom.NodeList 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 node list, specified as a double.

Attributes:

GetAccess
public
SetAccess
immutable
Transient
true
NonCopyable
true

Concatenated text content of the list items, specified as a character vector.

Attributes:

GetAccess
public
SetAccess
immutable
Transient
true
NonCopyable
true

Methods

expand all

Examples

collapse all

This example displays the text content of the day elements in the file days.xml by using the item method of the matlab.io.xml.dom.NodeList object that contains the elements.

Create a document from the days.xml file.

import matlab.io.xml.dom.*
doc = parseFile(Parser,"days.xml");

Call the getElementsByTagName method to return the element nodes named day as a matlab.io.xml.dom.NodeList object.

list = getElementsByTagName(doc,"day");

Display the text content of each element node in the list. Start with index 0 because the item method uses zero-based indexing.

n = getLength(list)-1;
for i = 0:n
   dayElem = item(list,i);
   disp(getTextContent(dayElem));
end
Mon
Tue
Wed
Thu
Fri

This example displays the text content of the day elements in the file days.xml by using the node method of the matlab.io.xml.dom.NodeList object that contains the elements.

Create a document from the days.xml file.

import matlab.io.xml.dom.*

doc = parseFile(Parser,"days.xml");

Call the getElementsByTagName method to return the element nodes named day as a matlab.io.xml.dom.NodeList object.

list = getElementsByTagName(doc,"day");

Display the text content of each element node in the list. Start with index 1 because the node method uses one-based indexing.

n = getLength(list);
for i = 1:n
   dayElem = node(list,i);
   disp(getTextContent(dayElem));
end
Mon
Tue
Wed
Thu
Fri

Version History

Introduced in R2021a