<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258382</link>
    <title>MATLAB Central Newsreader - strings and files and concatenations</title>
    <description>Feed for thread: strings and files and concatenations</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 13 Aug 2009 02:30:29 -0400</pubDate>
      <title>strings and files and concatenations</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258382#672686</link>
      <author>Andrew</author>
      <description>Below is a very abbreviated chunk of a much larger data file.  I want&lt;br&gt;
to write some code which will search through this file and pull all&lt;br&gt;
the values shown between &amp;lt;Quad&amp;gt; and &amp;lt;\Quad&amp;gt;.  There are hundreds of&lt;br&gt;
these sets of data in each file, and so I also want to assign a name&lt;br&gt;
or number to this set of data.  The name of the set is slot 1, which&lt;br&gt;
is shown in the first line below.  Can someone please explain how to&lt;br&gt;
pull the values out of this file?  I know how to use fopen, and a few&lt;br&gt;
string functions.  I have been able to find all the lines with &amp;lt;Quad&amp;gt;&lt;br&gt;
in it, but I can't figure out how to pull the values out or the string&lt;br&gt;
name.  Any help would be appreciated.  Thanks.&lt;br&gt;
&lt;br&gt;
&amp;lt;SlotData slot=&quot;001&quot;&amp;gt;&lt;br&gt;
&amp;lt;Notes&amp;gt;&amp;lt;/Notes&amp;gt;&lt;br&gt;
&amp;lt;Display&amp;gt;yes&amp;lt;/Display&amp;gt;&lt;br&gt;
&amp;lt;ForwardExciter&amp;gt;&lt;br&gt;
&amp;lt;Range&amp;gt;4A&amp;lt;/Range&amp;gt;&lt;br&gt;
&amp;lt;SpuPhaseData&amp;gt;0886&amp;lt;/SpuPhaseData&amp;gt;&lt;br&gt;
&amp;lt;SpuCalData&amp;gt;0810&amp;lt;/SpuCalData&amp;gt;&lt;br&gt;
&amp;lt;Quad&amp;gt;0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,&lt;br&gt;
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,&lt;br&gt;
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,&lt;br&gt;
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &amp;lt;/Quad&amp;gt;</description>
    </item>
    <item>
      <pubDate>Thu, 13 Aug 2009 03:19:05 -0400</pubDate>
      <title>Re: strings and files and concatenations</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/258382#672692</link>
      <author>Donn Shull</author>
      <description>Andrew &amp;lt;andrewkgentile@gmail.com&amp;gt; wrote in message &amp;lt;31f96cfe-2edb-4e72-bfe4-b82160584ea4@2g2000prl.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; Below is a very abbreviated chunk of a much larger data file.  I want&lt;br&gt;
&amp;gt; to write some code which will search through this file and pull all&lt;br&gt;
&amp;gt; the values shown between &amp;lt;Quad&amp;gt; and &amp;lt;\Quad&amp;gt;.  There are hundreds of&lt;br&gt;
&amp;gt; these sets of data in each file, and so I also want to assign a name&lt;br&gt;
&amp;gt; or number to this set of data.  The name of the set is slot 1, which&lt;br&gt;
&amp;gt; is shown in the first line below.  Can someone please explain how to&lt;br&gt;
&amp;gt; pull the values out of this file?  I know how to use fopen, and a few&lt;br&gt;
&amp;gt; string functions.  I have been able to find all the lines with &amp;lt;Quad&amp;gt;&lt;br&gt;
&amp;gt; in it, but I can't figure out how to pull the values out or the string&lt;br&gt;
&amp;gt; name.  Any help would be appreciated.  Thanks.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;lt;SlotData slot=&quot;001&quot;&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;Notes&amp;gt;&amp;lt;/Notes&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;Display&amp;gt;yes&amp;lt;/Display&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;ForwardExciter&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;Range&amp;gt;4A&amp;lt;/Range&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;SpuPhaseData&amp;gt;0886&amp;lt;/SpuPhaseData&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;SpuCalData&amp;gt;0810&amp;lt;/SpuCalData&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;Quad&amp;gt;0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,&lt;br&gt;
&amp;gt; 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,&lt;br&gt;
&amp;gt; 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,&lt;br&gt;
&amp;gt; 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &amp;lt;/Quad&amp;gt;&lt;br&gt;
&lt;br&gt;
Hi Andrew,&lt;br&gt;
&lt;br&gt;
This would appear to be an XML file, so I would suggest using xmlread to read it. For example if this were a file named SlotData.xml then&lt;br&gt;
&lt;br&gt;
dom = xmlread('SlotData.xml')&lt;br&gt;
&lt;br&gt;
would create a dom node. Then you can use the xml dom methods to extract the information you want.&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; doc = dom.getDocumentElement&lt;br&gt;
&amp;nbsp;&lt;br&gt;
doc =&lt;br&gt;
&amp;nbsp;&lt;br&gt;
[SlotData: null]&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; slotNumber = str2num(doc.getAttribute('slot'))&lt;br&gt;
&lt;br&gt;
slotNumber =&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;br&gt;
&lt;br&gt;
You can get a list of the Quad nodes with:&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; quadList = doc.getElementsByTagName('Quad')&lt;br&gt;
&amp;nbsp;&lt;br&gt;
quadList =&lt;br&gt;
&amp;nbsp;&lt;br&gt;
org.apache.xerces.dom.DeepNodeListImpl@1429c57&lt;br&gt;
&lt;br&gt;
The length of the list is given by:&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; quadList.getLength&lt;br&gt;
&lt;br&gt;
and you could process them with a loop&lt;br&gt;
for index = 0:quadList.getLength-1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;quadText(index+1) = quadList.item(index).getTextContent&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;% place processing commands here&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
Hope this helps,&lt;br&gt;
&lt;br&gt;
Donn</description>
    </item>
  </channel>
</rss>

