Encodexml: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Jeremy
(Importing text file)
imported>Jeremy
No edit summary
Line 1: Line 1:
===Purpose===
===Purpose===


Line 16: Line 15:
===Example===
===Example===


<pre>
>> z.a = 1;
>> z.a = 1;
>> z.b = { 'this' ; 'that' };
>> z.b = { 'this' ; 'that' };
>> z.c.sub1 = 'one field';
>> z.c.sub1 = 'one field';
>> z.c.sub2 = 'second field';
>> z.c.sub2 = 'second field';
>> z = encodexml(z,'mystruct')
>> z = encodexml(z,'mystruct')
z =
z =
 
&lt;mystruct>
<mystruct>
   &lt;a class="numeric" size="[1,1]">1</a>
 
   &lt;b class="cell" size="[2,1]">
   <a class="numeric" size="[1,1]">1</a>
     &lt;tr>
 
       &lt;td class="string">this</td>
   <b class="cell" size="[2,1]">
     &lt;/tr>
 
     &lt;tr>
     <tr>
       &lt;td class="string">that</td>
 
     &lt;/tr>
       <td class="string">this</td>
   &lt;/b>
 
   &lt;c>
     </tr>
     &lt;sub1 class="string">one field</sub1>
 
     &lt;sub2 class="string">second field</sub2>
     <tr>
   &lt;/c>
 
&lt;/mystruct>
       <td class="string">that</td>
</pre>
 
     </tr>
 
   </b>
 
   <c>
 
     <sub1 class="string">one field</sub1>
 
     <sub2 class="string">second field</sub2>
 
   </c>
 
</mystruct>
 
===See Also===
===See Also===


[[encode]], [[parsexml]]
[[encode]], [[parsexml]]

Revision as of 09:31, 4 September 2008

Purpose

Convert standard data types into XML-encoded text.

Synopsis

xml = encodexml(var)
xml = encodexml(var,'name')
xml = encodexml(var,'name','outputfile.xml')

Description

Converts a standard Matlab variable (var) into a human-readable XML format. The optional second input ('name') gives the name for the object's outer wrapper and the optional third input ('filename.xml') gives the name for the output file (if omitted, the XML is only returned in the output variable). For more information on the format, see the PARSEXML function.

Example

>> z.a = 1;
>> z.b = { 'this' ; 'that' };
>> z.c.sub1 = 'one field';
>> z.c.sub2 = 'second field';
>> z = encodexml(z,'mystruct')
z =
<mystruct>
  <a class="numeric" size="[1,1]">1</a>
  <b class="cell" size="[2,1]">
    <tr>
      <td class="string">this</td>
    </tr>
    <tr>
      <td class="string">that</td>
    </tr>
  </b>
  <c>
    <sub1 class="string">one field</sub1>
    <sub2 class="string">second field</sub2>
  </c>
</mystruct>

See Also

encode, parsexml