comparison m-toolbox/classes/+utils/@prog/obj2xml.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % OBJ2XML Converts an object to an XML representation
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: Converts an object to XML representation.
5 %
6 % CALL: xml = utils.prog.obj2xml(obj)
7 %
8 % INPUTS: obj - the object to be converted
9 %
10 % OUTPUTS: xml - the converted object
11 %
12 % EXAMPLE:
13 %
14 % VERSION: $Id: obj2xml.m,v 1.1 2010/05/17 08:55:25 nicolodi Exp $
15 %
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17
18 function str = obj2xml(obj)
19
20 % make pointer to xml document
21 xml = com.mathworks.xml.XMLUtils.createDocument('ltpda_object');
22
23 % extract parent node
24 parent = xml.getDocumentElement;
25
26 % add an 'ltpda_version' attribute to the root node
27 ltpda_version = getappdata(0, 'ltpda_version');
28 parent.setAttribute('ltpda_version', ltpda_version);
29
30 % write obj into xml
31 utils.xml.xmlwrite(obj, xml, parent, '');
32
33 % convert into a string
34 str = xmlwrite(xml);
35 end