%% Create a Text Node for an XML DOM Document
% Create a text node to append to a document element by using the createTextNode method of the matlab.io.xml.dom.Document object that represents the document.
% Import the matlab.io.xml.dom package so that you do not have to use long, fully qualified class names.

import matlab.io.xml.dom.*

% Create a document with a root element named  employee.

doc = Document("employee");
employeeElem = getDocumentElement(doc);

% Create an element named jobtitle .

jobtitleElem = createElement(doc,"jobtitle");

% Create a text node for the jobtitle text content and append the text note to the jobtitle element.

textNode = createTextNode(doc,"Manager");
appendChild(jobtitleElem,textNode);

% Append the jobtitle element to the employeeElem element.

appendChild(employeeElem,jobtitleElem);

% Write the XML to a file.

xmlFileName = "employee.xml";
writer = matlab.io.xml.dom.DOMWriter;
writeToFile(writer,doc,xmlFileName);

%
% Copyright 2020 The MathWorks, Inc.