Rank: 346 based on 382 downloads (last 30 days) and 2 files submitted
photo

Wouter Falkena

E-mail
Company/University
Delft University of Technology
Lat/Long
51.99001312255859, 4.375315189361572

Personal Profile:

 

Watch this Author's files

 

Files Posted by Wouter Falkena View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
15 May 2012 xml2struct Convert an xml file into a MATLAB structure for easy access to the data. Author: Wouter Falkena xml, xml2struct, struct 313 29
  • 4.8
4.8 | 31 ratings
02 Jan 2012 struct2xml Convert a MATLAB structure into a XML file. Author: Wouter Falkena struct2xml, struct, xml 69 17
  • 4.28571
4.3 | 14 ratings
Comments and Ratings by Wouter Falkena View all
Updated File Comments Rating
04 Jan 2012 struct2xml Convert a MATLAB structure into a XML file. Author: Wouter Falkena

Hi Harald,

The reason why the function requires a single field in the main structure is that a properly formatted XML document has a single root element (http://www.w3schools.com/xml/xml_dtd.asp). The only exception to that rule is a more elaborate XML preamble, which is currently not supported by the function.

For the second point, XML files usually have multiple elements with the same name. In order to convert this into a MATLAB structure, an array may be used. This means that isstruct(s.(curfield)) indeed may not work, but in that case
if iscell(s.(curfield))
min(cellfun(@(a) isstruct(a),s.curfield))
end
will tell you if all cells in the array are structures.

I hope this clarifies how to use the function a bit. If you have any more questions feel free to contact me.

Regards,
Wouter

02 Jan 2012 struct2xml Convert a MATLAB structure into a XML file. Author: Wouter Falkena

Hi Emil,

The function indeed replaces the characters -:. with _ (also see the function help). It should be possible to rewrite the function to replace : with something unique like _colon_ and let struct2xml replace this with :. Let me know if you still need this functionality. The structure names do get longer in that way...

Regards,
Wouter

19 Sep 2011 struct2xml Convert a MATLAB structure into a XML file. Author: Wouter Falkena

Thank you Herbert for finding and successfully eradicating this bug. I have uploaded the fixed file to the MATLAB Central.

04 Jul 2011 xml2struct Convert an xml file into a MATLAB structure for easy access to the data. Author: Wouter Falkena

Thank you for this suggestion Mr. Wanner. I have updated the file and it is currently under review by the MATLAB Central. It will appear here shortly.

13 Apr 2011 struct2xml Convert a MATLAB structure into a XML file. Author: Wouter Falkena

You are correct. However, isspace does not operate on cells. In the latest update I removed the for-loop all together and use isspace on the multi-line string. This is the fastest approach yet. Again, thank you for your support.

Comments and Ratings on Wouter Falkena's Files View all
Updated File Comment by Comments Rating
06 Nov 2014 xml2struct Convert an xml file into a MATLAB structure for easy access to the data. Author: Wouter Falkena Chris FUNG

09 Oct 2014 xml2struct Convert an xml file into a MATLAB structure for easy access to the data. Author: Wouter Falkena Sebastien Roy

Great time saver when compared to using xmlread directly. However, there is a bug with child nodes when a text is present. The child node content will be set to the text and all other content of the child will be lost. A comment, being processed as text, will cause the same issue. Attempting to read this xml will not provide the expected result:

<?xml version="1.0" encoding="UTF-8"?>

<root>
<!-- Should be a benign comment -->
<mystuff>Valuable data</mystuff>
</root>

13 Aug 2014 struct2xml Convert a MATLAB structure into a XML file. Author: Wouter Falkena Markus Fischer

13 Jun 2014 struct2xml Convert a MATLAB structure into a XML file. Author: Wouter Falkena Raúl

Great script. I don't know why my struct 'S' is not written in a xml file. I'm using the following statement

file = struct2xml(S);

Where 'file' is the xml file where I want to save the struct and S my struct. However, non xml file is created. Can you help me? What am I missing?
Thanks

12 Jun 2014 xml2struct Convert an xml file into a MATLAB structure for easy access to the data. Author: Wouter Falkena Simon du Plooy

Some of the attributes in the XML file had underscores at the beginning which error because of disallowed field name. Simple strrep solved the problem.

Great!

Contact us