File: struct_2_xml.m

package info (click to toggle)
openems 0.0.35%2Bgit20190103.6a75e98%2Bdfsg.1-3.2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 8,544 kB
  • sloc: cpp: 40,417; python: 2,028; yacc: 580; makefile: 459; lex: 350; sh: 176; ruby: 19
file content (23 lines) | stat: -rw-r--r-- 810 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function struct_2_xml(filename, xml_struct, rootName);

if ~isOctave()
	docNode = com.mathworks.xml.XMLUtils.createDocument(rootName);
	docElem = docNode.getDocumentElement;
	
	docElem = struct_2_xmlNode(docNode, docElem, xml_struct);
	
	% Save the sample XML document.
	xmlFileName = [filename];
	xmlwrite(xmlFileName,docNode);
else
%	% for octave you need the octave_xmltoolbox (C) 2007 Thomas Geiger
%	% http://wiki.octave.org/wiki.pl?XMLToolboxPort
%	xml_struct = octave_struct2xml( xml_struct, rootName );
%	xml_save( filename, xml_struct, 'any' );

%	xml_toolbox is buggy (sequence of elements is not preserved)
	fid = fopen( filename, 'w' );
	fprintf( fid, '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>\n' );
	fprintf( fid, octave_struct2xml_2(xml_struct,rootName,'') );
	fclose( fid );
end