Converting XML File to variable
Show older comments
Hello, I have a file is an xmlfile that has data that looks like what is below. I am trying to figure out how to get it into a matrix in MATLAB. Any good ideas? Thanks, Sarah C
<?xml version="1.0" encoding="utf-8"?>
<Data Name="Name" Count="401">
<Complex Real="280748.84310499707" Imag="-731405.72583204659" Unit="" Frequency="1000" />
<Complex Real="45059.269195067369" Imag="-271499.36286958907" Unit="" Frequency="3002.5" />
<Complex Real="-36154.192805897859" Imag="-163614.26207791027" Unit="" Frequency="5005" />
<Complex Real="-4452.0673371766252" Imag="-111209.63843556584" Unit="" Frequency="7007.5" />
<Complex Real="8099.087999428838" Imag="-101402.77961163782" Unit="" Frequency="9010" />
<Complex Real="-1894.0244655687259" Imag="-73468.12686001345" Unit="" Frequency="11012.5" />
<Complex Real="8568.9595511108546" Imag="-75491.2864970298" Unit="" Frequency="13015" />
<Complex Real="5334.2838461946949" Imag="-60597.456672208747" Unit="" Frequency="15017.5" />
<Complex Real="2503.9489540662771" Imag="-55784.349731678987" Unit="" Frequency="17020" />
<Complex Real="3116.8638014549178" Imag="-50413.798533633955" Unit="" Frequency="19022.5" />
<Complex Real="865.953785725421" Imag="-43814.683639568029" Unit="" Frequency="21025" />
<Complex Real="883.22801790775759" Imag="-44063.356350793285" Unit="" Frequency="23027.5" />
<Complex Real="1627.6463059320986" Imag="-39561.493634241684" Unit="" Frequency="25030" />
<Complex Real="644.33320448597112" Imag="-35938.985737989351" Unit="" Frequency="27032.5" />
<Complex Real="1135.0800449998465" Imag="-32970.493495540548" Unit="" Frequency="29035" />
<Complex Real="1322.8158532866823" Imag="-31537.729941376481" Unit="" Frequency="31037.5" />
<Complex Real="1927.0437287920684" Imag="-29540.153061959161" Unit="" Frequency="33040" />
<Complex Real="851.5875749724446" Imag="-27065.861851929178" Unit="" Frequency="35042.5" />
<Complex Real="1685.1996437370808" Imag="-25115.876515081804" Unit="" Frequency="37045" />
<Complex Real="1144.673326865078" Imag="-24813.313962959688" Unit="" Frequency="39047.5" />
<Complex Real="911.65309188236836" Imag="-23309.135072092897" Unit="" Frequency="41050" />
1 Comment
per isakson
on 12 Jul 2017
Edited: per isakson
on 12 Jul 2017
Answers (1)
Walter Roberson
on 12 Jul 2017
0 votes
You might want to experiment with https://www.mathworks.com/matlabcentral/fileexchange/28518-xml2struct
Categories
Find more on Structured Data and XML Documents in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!