Error with xml files and Matlab structures
Mostra commenti meno recenti
I am trying to modify an xml file through Matlab.
In order to do it, I am using this to convert the xml file into a Matlab structure and this other one to get the xml file back.
The problem is: I encounter an error when I try to convert the Matlab structure back into an xml file. The error is:
if true
Error using xmlwrite (line 82)
Java exception occurred:
java.lang.NullPointerException
at com.mathworks.xml.XMLUtils.serializeXML(XMLUtils.java:192)
at com.mathworks.xml.XMLUtils.serializeXML(XMLUtils.java:49)
Error in struct2xml (line 79)
varargout{1} = xmlwrite(docNode);
Error in read_change_timestamps (line 5)
test.xml = struct2xml(eci);
end
It has to do with the second function "struct2xml", but I can't seem to understand what exactly is the problem.
This is an example of an xml file that I'm trying to modify:
if true
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<eventTrack xmlns="http://www.egi.com/event_mff" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<name>ECI TCP/IP 55513</name>
<trackType>STIM</trackType>
<event>
<beginTime>2017-04-04T14:15:43.529000+00:00</beginTime>
<duration>1000</duration>
<code>Task</code>
<label></label>
<description></description>
<sourceDevice>Multi-Port ECI</sourceDevice>
<keys>
<key>
<keyCode>dura</keyCode>
<data dataType="short">147</data>
</key>
</keys>
</event>
<event>
<beginTime>2017-04-04T14:15:45.979000+00:00</beginTime>
<duration>1000</duration>
<code>stim</code>
<label></label>
<description></description>
<sourceDevice>Multi-Port ECI</sourceDevice>
<keys>
<key>
<keyCode>tria</keyCode>
<data dataType="short">1</data>
</key>
<key>
<keyCode>code</keyCode>
<data dataType="short">70</data>
</key>
<key>
<keyCode>type</keyCode>
<data dataType="short">2</data>
</key>
</keys>
</event>
<event>
<beginTime>2017-04-04T14:15:46.096000+00:00</beginTime>
<duration>1000</duration>
<code>ISI </code>
<label></label>
<description></description>
<sourceDevice>Multi-Port ECI</sourceDevice>
<keys>
<key>
<keyCode>dura</keyCode>
<data dataType="short">164</data>
</key>
</keys>
</event>
<event>
<beginTime>2017-04-04T14:15:48.830000+00:00</beginTime>
<duration>1000</duration>
<code>stim</code>
<label></label>
<description></description>
<sourceDevice>Multi-Port ECI</sourceDevice>
<keys>
<key>
<keyCode>tria</keyCode>
<data dataType="short">2</data>
</key>
<key>
<keyCode>code</keyCode>
<data dataType="short">149</data>
</key>
<key>
<keyCode>type</keyCode>
<data dataType="short">1</data>
</key>
</keys>
</event>
<event>
<beginTime>2017-04-04T14:15:48.930000+00:00</beginTime>
<duration>1000</duration>
<code>ISI </code>
<label></label>
<description></description>
<sourceDevice>Multi-Port ECI</sourceDevice>
<keys>
<key>
<keyCode>dura</keyCode>
<data dataType="short">159</data>
</key>
</keys>
</event>
<event>
<beginTime>2017-04-04T14:15:51.580000+00:00</beginTime>
<duration>1000</duration>
<code>stim</code>
<label></label>
<description></description>
<sourceDevice>Multi-Port ECI</sourceDevice>
<keys>
<key>
<keyCode>tria</keyCode>
<data dataType="short">3</data>
</key>
<key>
<keyCode>code</keyCode>
<data dataType="short">66</data>
</key>
<key>
<keyCode>type</keyCode>
<data dataType="short">2</data>
</key>
</keys>
</event>
<event>
<beginTime>2017-04-04T14:15:51.680000+00:00</beginTime>
<duration>1000</duration>
<code>ISI </code>
<label></label>
<description></description>
<sourceDevice>Multi-Port ECI</sourceDevice>
<keys>
<key>
<keyCode>dura</keyCode>
<data dataType="short">147</data>
</key>
</keys>
</event>
</eventTrack>
end
What could possibly be the problem with it? Is it because of the structure of the original xml file?
2 Commenti
Guillaume
il 14 Mag 2017
Either it's a bug in struct2xml or there's something wrong with the structure you're trying to write.
Either way, we need that structure to find out, so attach it to your post as a mat file.
Also, which version of matlab are you using?
Nicolò Trevisan
il 15 Mag 2017
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Structured Data and XML Documents in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!