xml2struct

xml2struct(file)

Convert xml file into a MATLAB structure [ s ] = xml2struct( file )

A file containing: <XMLname attrib1=”Some value”>

<Element>Some text</Element> <DifferentElement attrib2=”2”>Some more text</Element> <DifferentElement attrib3=”2” attrib4=”1”>Even more text</DifferentElement>

</XMLname>

Will produce: s.XMLname.Attributes.attrib1 = “Some value”; s.XMLname.Element.Text = “Some text”; s.XMLname.DifferentElement{1}.Attributes.attrib2 = “2”; s.XMLname.DifferentElement{1}.Text = “Some more text”; s.XMLname.DifferentElement{2}.Attributes.attrib3 = “2”; s.XMLname.DifferentElement{2}.Attributes.attrib4 = “1”; s.XMLname.DifferentElement{2}.Text = “Even more text”;

Please note that the following characters are substituted ‘-’ by ‘_dash_’, ‘:’ by ‘_colon_’ and ‘.’ by ‘_dot_’

Written by W. Falkena, ASTI, TUDelft, 21-08-2010 Attribute parsing speed increased by 40% by A. Wanner, 14-6-2011 Added CDATA support by I. Smirnov, 20-3-2012

Modified by X. Mo, University of Wisconsin, 12-5-2012