%% Specify Attribute Suffix
% Specify the field names in the input structure to write as attributes in the output XML file.
% Read the file music.xml as a structure S. Append the suffix "_att" to the field names of the output structure that correspond to attributes in the input XML file.

S = readstruct("music.xml", "AttributeSuffix", "_att")

% All elements in S that have associated attributes will have the suffix "_att" appended to the attribute names.
% Query the field Musicians to view its contents. Musicians is a structure that contains five structures, each of which contain a field called Name with an associated attribute called role.

S.Musicians.Name

% Write S to the XML file named band.xml and display its contents. The suffix "_att" has been appended to the attribute names in the file.

writestruct(S,"band.xml")
type band.xml
writestruct(S,"band.xml","AttributeSuffix","_att")

% Write the structure S to the XML file again, this time specifying the value of "AttributeSuffix" as "_att" to indicate which field names in the input structure to write as attributes. Display the contents of band.xml. The attributes in  band.xml do not have the suffix "_att".

type band.xml

% Copyright 2020 The MathWorks, Inc.