⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmltree.m

📁 matlab数字信号处理工具箱
💻 M
字号:
function tree = xmltree(varargin)
% XMLTREE/XMLTREE Constructor of the XMLTree class
% FORMAT tree = xmltree(varargin)
% 
% varargin - XML filename or XML string
% tree     - XMLTree Object
%
%     tree = xmltree;             % creates a minimal XML tree: '<tag/>'
%     tree = xmltree('foo.xml');  % creates a tree from XML file 'foo.xml'
%     tree = xmltree('<tag>content</tag>') % creates a tree from string
%_______________________________________________________________________
%
% This is the constructor of the XMLTree class. 
% It creates a tree of an XML 1.0 file (after parsing) that is stored 
% using a Document Object Model (DOM) representation.
% See http://www.w3.org/TR/REC-xml for details about XML 1.0.
% See http://www.w3.org/DOM/ for details about DOM platform.
%_______________________________________________________________________
% @(#)xmltree.m                 Guillaume Flandin              02/03/27

switch(nargin)
	case 0
		tree.tree{1} = struct('type','element',...
		                      'name','tag',...
						      'attributes',[],...
						      'contents',[],...
							  'parent',[],...
						      'uid',1);
		tree.filename = '';
		tree = class(tree,'xmltree');
	case 1
		if isa(varargin{1},'xmltree')
			tree = varargin{1};
		elseif ischar(varargin{1})
			% Input argument is an XML string
			if (exist(varargin{1}) ~= 2 & ...
				~isempty(xml_findstr(varargin{1},'<',1,1)))
				tree.tree = xml_parser(varargin{1});
				tree.filename = '';
			% Input argument is an XML filename
			else
				fid = fopen(varargin{1},'rt');
				if (fid == -1) 
					error(['[XMLTree] Cannot open ' varargin{1}]);
				end
				xmlstr = fscanf(fid,'%c');
				fclose(fid);
				tree.tree = xml_parser(xmlstr);
				tree.filename = varargin{1};
			end
			tree = class(tree,'xmltree');
		else 
			error('[XMLTree] Bad input argument');
		end
	otherwise
		error('[XMLTree] Too many input arguments');
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -