xml2struct takes either a java xml object, an xml file, or a string in xml format and returns a structure that preserves the tree relationship in the xml document. It is an improved version of another MATLAB file exchange submission : https://www.mathworks.com/matlabcentral/fileexchange/28518-xml2struct .
Specifically, it has following features:
1. Solved the issue that when comment is present, other data will be lost.
2. Fixed the " Undefined function 'toCharArray' for input arguments of type 'double'. " issue.
3. Added support for xml string.
CY Y (2019). xml2struct , with bug fix and added features (https://www.github.com/joe-of-all-trades/xml2struct), GitHub. Retrieved .
1.0.0.0 | Fixed the " Undefined function 'toCharArray' for input arguments of type 'double'. " issue. |
|
1.0.0.0 | updated description |
|
1.0.0.0 | Updated title |
|
1.0.0.0 | Updated description. |
|
1.0.0.0 | linked to github |
|
1.0.0.0 | added tags |
|
1.0.0.0 | Minor changes in code comment |
Create scripts with code, output, and formatted text in a single executable document.
Hongxiao Jin (view profile)
Kiarash Ahi (view profile)
I wonder if there is any python equivalent of this script?
Jiayan Liu (view profile)
Gernot Druml (view profile)
Manfred Rabl-Pöchacker (view profile)
Thank you for solving the " Undefined function 'toCharArray' for input arguments of type 'double'. " issue.
It saves me from editing hundreds of files per hand!
BINH LE (view profile)
Thank you very much for such a great tool.
BTW, when convert XML element's name to match MATLAB struct field name requirements,
name = strrep(name, '_', 'u_'); should be the first before '-', ':' , '.' to avoid unintentional effect.
E.g: "a:int" turns into "au_colon_int" instead of "a_colon_int".
Jan L (view profile)
Siddharth singh (view profile)
showing unexpected MATLAB '<' Operator for the following xml file
https://msdn.microsoft.com/en-us/library/ms762271(v=vs.85).aspx
john (view profile)
Kresten (view profile)
M.Abuasbeh (view profile)
Thanks Joe Yeh!
Very helpful!
subhasis adhikari (view profile)
How do I get data from the output structure file? I have an XML file containing an image file. I want to read this XML file which I can do it using this program. Now, I want to make the image but I don't know how to get my data from the structure file which I get using this program.
Timofey Goloborodko (view profile)
CY Y (view profile)
to Mark Tolman and Arun M, I think this issue should be resolved now. I've changed toCharArray() to char(), which should always be present in MATLAB.
KAE (view profile)
I tried this when the example in the xmlread documentation didn't work for my XML file, and this did, so thanks. I also found the output structure's organization to be easy to work with and understand.
Arun M (view profile)
How to deal with the following error?
Undefined function 'toCharArray' for input arguments of type 'double'.
Wee-Lih Lee (view profile)
Michael Helmberger (view profile)
Darshan Shah (view profile)
great help
Mark Tolman (view profile)
I'm getting the following error. Should I by importing something prior to using this script? How do I fix it?
Undefined function 'toCharArray' for input arguments of type 'double'.
Error in xml2struct_fixed>getNodeData (line 153)
text.(textflag) = toCharArray(getTextContent(theNode))';
SACHIT VARMA (view profile)
Very useful !
Just one problem, the fields in my xml file are not starting with a _ but are in the middle. Still the _ are being replaced by a u_
CY Y (view profile)
Thank you. Very useful !
CY Y (view profile)
@ Herve , I don't have such script available but I think the solution you posted on the other file exchange entry is a valid one.
Herve Demezil (view profile)
is there a file to revert the operation compatible with R2016a? The one in https://fr.mathworks.com/matlabcentral/fileexchange/28639-struct2xml crash during execution
CY Y (view profile)
Thanks R S for pointing this out. Now the leading _ in the node name will be replaced with u_ . Field name of a MATLAB struct can not begin with an _ .
R S (view profile)
There is an error when node name begins with '_'. Try loading MS Visual Studio (2010) project vcxproj file.
CY Y (view profile)
@Ian, thanks for the comment. I've fixed the issue.
Ian Craig (view profile)
There is an error on line 79 (I opened a git issue on it), but otherwise very well done.
Yoann Ladroit (view profile)
Looks robust. Rather fast as well! REally useful to me thanks very much!