File Exchange

image thumbnail

XML parsing tools

version 1.0.0.0 (142 KB) by Charles Lehalle
xmltools is a MATLAB tool designed to handle XML data.

10 Downloads

Updated 05 Oct 2005

No License

xmltool is provided with a explanation pdf file produced with ocamaweb.
this new version allow to request only a given type of tags.

see up-to-date version on sourceforge :
https://sourceforge.net/project/showfiles.php?group_id=72934

Cite As

Charles Lehalle (2020). XML parsing tools (https://www.mathworks.com/matlabcentral/fileexchange/3074-xml-parsing-tools), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (8)

Peter bjerg

Hi. I'm trying to use xml_parse on a 114299 long string. Shorter strings goes well. No error messages or anything?
Any suggestions??

br Peter

Peter bjerg

Hi. I' trying to use xml_parse on a string which is 114299 long, but get only an empty struck back. Have tried it on shorter strings from same device and no problems?? Any sugestions??
No error messages or anything

br PEter

bathmarm0t

This tool worked EXCELLENT after putting in a few modifications. I am exporting / inporting XMLs from an adobe acrobat file so formatting was important. The main things causing problems were the calls to upper() and newline / margin management.

Heres my workarounds (added removal of newlines from pdfs exported xml (this code needs solid containers e.g. <c>something</c>)
%< Récupération du fichier dans un string
fid = fopen(arg, 'r');
F = fread(fid);

%Loop through. Find the sequence \n> and remove newline.
i = 1;
numChars = length(F);
while i < numChars
if F(i) == 10 %char(10) is \n
if F(i+1) == 62 %char(62) is >
F(i:end-1) = F(i+1:end); %Shift left
numChars = numChars-1;
end
end
i = i+1;
end
%Truncate the extra bits on the end
F = F(1:numChars);

s = char(F');
fclose(fid);
%>

And then I removed all calls to upper (except on strcmps / case switches) and set
margin = '';

Many thanks.

Raymundo

Hey,
I am trying to use your function but I got this message. Is there any way to fix this or should I divide the file in smaller parts?

??? Maximum recursion limit of 500 reached. Use
set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available stack
space can
crash MATLAB and/or your computer.

Error in ==> num2cell

Jesse Hopkins

Good tool, but runs slow for large files, and does not handle xml comments as is, but wasn't too hard to figure out how to fix that. I actually think the syntax
z.child(2).child(1).child(2).attribs(2)
works better than other matlab xml tools on the file exchange, as the structure will always be the same format no matter what the xml file. This also handles repetative tag names, which the others that I've seen do not. You can make it more readable by using intermediate variables suchas:
mysubsystem = z.child(1)
mysub_subsystem = mysubsystem.child(1)
etc..

Michel Thierry

Good tool, but it doesn't handle CDATA elements (which should not be parsed, but should be kept within the parsed structure as text).

Pierre Joly

A very good tool.
After interesting exchanges with the author, it turns out that the syntax "z.child(2).child(1).child(3).child.attribs(2)", which is not very nice, cannot be more specific to the file (as z.root.thirdbranch.otherbranch.myleaf) because the tree described by an xml file can have branches with the same name and different structures. According to Charles Lehalle, future developments of the tool should include friendlier ways to access to the data. This is a good reason to subscribe to the automatic notification of changes of the file.

charles lehalle

an up-to-date version of this file will be downloadable at https://sourceforge.net/project/showfiles.php?group_id=72934
you can submit bugs or features requets there too.

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!