I am using your tool very often and I want to thank you for that.
This week I found a little problem and do not knwo how to solve. First of all my xml file:
<measurement>
<values>
<value>
<rssi>-90</rssi>
<identifier>
<name>00-11-88-87-F4-82</name>
</identifier>
</value>
</values>
</measurement>
<measurement>
<values>
<value>
<rssi>-81</rssi>
<identifier>
<name>00-11-88-88-42-40</name>
</identifier>
</value>
</values>
</measurement>
Reading the first part is working, so I get a string called '00-11-88-87-F4-82' with the RSSI value. WIth the second part there is a problem. Because there are only numbers in the string, xmlread does not interpret it as a string. It calcluates the the value of -269. But I need it as String because it is not a number.
How can I solve the problem? Changing the name is not possible because it is given by the application where the xml is coming from.
thank you for your help. I compiled it with a new Matlab and it is working fine now. But one problem again: How can I see which AP (Mac-Address) has which RSSI values? At the moment I only get RSSI values as I specified but I do not knwo from which AP? Is it possible to get something like this:
MAC1: RSSI1, RSSI2, RSSI3,...
MAC2: RSSI1, RSSI2, RSSI3,...
very nice idea your WifiRSSI. But i have a problem using it. Here my setup: Matlab R2007b and WindowsXP SP3. The driver can be started successfully:
>> !net start ndisprot
The EP_NSWD NDIS Protocol Driver service was started successfully.
But if I use your examples like
y = wifiRSSI([] , 100 , 10);
I get errors:
??? Invalid MEX-file 'C:\Documents and Settings\Mark Weber\My
Documents\MATLAB\WIPoS\wifiRSSI.dll': The
specified module could not be found.
Recompiling is very difficult because VS 2008 is installed on my system. Maybe you have an idea? The right workspace is selected with wifiRSSI.dll and wifidevice.dll in it.
Hej,
I just noticed, that the xml_read function does not detect arrays correctly from attributes of xml-nodes.
I use the str2num=smart default option. I found, that there is an error in the str2var function on line 452 where I just removed the square brackets from the digit array:
digits = '(Inf)|(NaN)|(pi)|[\t\n\d\+\-\*\.ei EI\;\,]';
Now it works again like a charm. Great work by the way. Hope you can add the bugfix to a future release.
Daniel
Comment only
22 Dec 2011
xml_io_tools
Read XML files into MATLAB struct and writes MATLAB data types to XML
Jaroslaw,
Thanks for this excellent work. I enjoy using it, so I wanted to share what I did to possibly improve "xml_read".
Reading in the following .xml file:
<?xml version="1.0" encoding="utf-8"?>
<ROOT>
<xtr_base>
<item>0x30010</item>
</xtr_base>
<reg_base>0x30000</reg_base>
<pcm_base>
<item>0x30040</item>
<item>0x30050</item>
</pcm_base>
</ROOT>
I performed the following commands:
>> D3=xml_read('testrdsmall_jec.xml');
>> D3
D3 =
xtr_base: '0x30010'
reg_base: '0x30000'
pcm_base: {'0x30040' '0x30050'}
It bothered me that the resulting data structure in Matlab has both xtr_base and reg_base the same. I tried using Pref.CellItem=true, as in the following commands:
>> Pref.CellItem=true;
>> D2=xml_read('testrdsmall_jec.xml',Pref);
>> D2
D2 =
xtr_base: {'0x30010'}
reg_base: '0x30000'
pcm_base: {{1x2 cell}}
This did produce a difference between xtr_base and reg_base, but the pcm_base was now a cell-array within a cell-array! So, I decided to make a modification to your code...
So now, with my small modification, I do the following commands:
>> D5=xml_read_jec('testrdsmall_jec.xml');
>> D5
D5 =
xtr_base: {'0x30010'}
reg_base: '0x30000'
pcm_base: {'0x30040' '0x30050'}
It produces the result I expect. However, when I use Pref.CellItem=true, I get:
>> D=xml_read_jec('testrdsmall_jec.xml',Pref);
>> D
D =
xtr_base: {'0x30010'}
reg_base: '0x30000'
pcm_base: {{1x2 cell}}
... which is probably not exactly as it should be. So, maybe my modification is not entirely correct.
What I did was to change lines 383-387 from this:
if (isfield(s,Pref.ItemName))
s.CONTENT = s.(Pref.ItemName);
s = rmfield(s,Pref.ItemName);
ItemContent = Pref.CellItem; % if CellItem than keep s.CONTENT as cells
end
to be this instead:
if (isfield(s,Pref.ItemName))
% Check for singleton nodes that have the special keyword to mark arrays,
% and keep them as cell arrays, even though the resulting cell array
% only has one member. -- Modification by John Clayton, 12/22/11.
if ~iscell(s.(Pref.ItemName))
s.CONTENT = s.(Pref.ItemName);
s = rmfield(s,Pref.ItemName);
ItemContent = true;
else
s.CONTENT = s.(Pref.ItemName);
s = rmfield(s,Pref.ItemName);
ItemContent = Pref.CellItem; % if CellItem then keep s.CONTENT as cells
end
end
What do you think of this change? Perhaps I did it not very well, but I wanted to tell you about it.
Thanks again for your excellent work!
- John Clayton
5
14 Dec 2011
xml_io_tools
Read XML files into MATLAB struct and writes MATLAB data types to XML
Comment only