How can I modify an XML file and create a new XML file ?

50 views (last 30 days)
close all
clear all
clc
%% lecture fichier xml
V=xml2struct( 'V4_charles.xml');
%% Données
Angle_base=0:0.5:5; %angle de dièdre à la base de l'aile
Angle_tip=0:1:15; %angle dièdre tip
span=str2double(V.xflplane.Plane.wing{1, 1}.Sections.Section{1, 3}.yu_position.Text);
Pos_tip=(0.5:0.02:1)*span ; % position tip en poucentage du span de l'aile
%% modification fichier
for n=Angle_base;
temp=V;
temp.xflplane.Plane.wing{1, 1}.Sections.Section{1, 1}.Dihedral.Text=convertStringsToChars(n);% modificiation angle dièdre
filename=['V_' num2str(n) '.xml'];%%nouveau nom
xmlwrite(filename,temp); %écriture nouveau fichier xml
end
And I get these error messages:
No constructor 'javax.xml.transform.dom.DOMSource' with matching signature
found.
Error in xmlwrite>xmlWriteHelper (line 131)
xSource = javax.xml.transform.dom.DOMSource(node);
Error in xmlwrite (line 78)
xmlWriteHelper(result,source,varargin{1});
Error in plane_modification (line 17)
xmlwrite(filename,temp); %écriture nouveau fichier xml

Answers (1)

Anmol Dhiman
Anmol Dhiman on 10 Dec 2020
Hi Jules,
As mentioned in this Answer , use xmlread and xmlwrite to modify.
Regards,
Anmol Dhiman

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!