Parsexml: 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 10: Line 9:
===Description===
===Description===


===Creates Matlab object from XML file. The format of the file must follow that used by ENCODEXML. Each XML tag will be encoded as a field in a Matlab structure. The top-level tag will be the single field in the top-level of the returned structure and all sub-tags will be sub-fields therein. Contents of those fields can be specified using the following attributes:===
Creates Matlab object from XML file. The format of the file must follow that used by ENCODEXML. Each XML tag will be encoded as a field in a Matlab structure. The top-level tag will be the single field in the top-level of the returned structure and all sub-tags will be sub-fields therein. Contents of those fields can be specified using the following attributes
 
===Tags with the attribute 'class' will be encoded using these rules:===


===class="numeric"  : Contents of tag must be comma-delimited list of values with rows delimited by semicolons. Each row must have the same number of values (equal in length) or an error will result. Multi-way matricies can be encapulated in <tn mode="i"> tags where i is the mode that the enclosed item expands on (i>=3).===
Tags with the attribute 'class' will be encoded using these rules


===class="cell"     : Contents encoded as Matlab cell. Format of contents is same as HTML table tags (<tr> for new row, <td> for new container/column) with the added tag of <tn mode="i"> to describe an multi-dimensional cell (see class="numeric").===
:class="numeric"   : Contents of tag must be comma-delimited list of values with rows delimited by semicolons. Each row must have the same number of values (equal in length) or an error will result. Multi-way matricies can be encapulated in &lt;tn mode="i"&gt; tags where i is the mode that the enclosed item expands on (i>=3).


===class="string"   : Contents encoded as string or padded string array. If multiple row string, each row should be enclosed in <sr> tags. ===
:class="cell"     : Contents encoded as Matlab cell. Format of contents is same as HTML table tags (&lt;tr&gt; for new row, &lt;td&gt; for new container/column) with the added tag of &lt;tn mode="i"&gt; to describe an multi-dimensional cell (see class="numeric").


===class="structure" : Used for struture arrays ONLY. Contents encoded into a structure array using array notation identical to that described for class="cell". If a structure is size [1 1] then it does not need to use array notation and must not be marked with this class attribute. Instead, the contents of the structure should simply be enclosed within the tag as sub-tags.===
:class="string"   : Contents encoded as string or padded string array. If multiple row string, each row should be enclosed in &lt;sr&gt; tags.


===class="dataset"   : Contents will be interpreted as a DataSet Object. Any tags which do not map to valid DataSet Object fields will be ignored. See the DataSet definition for details on valid fields and ENCODEXML for example of DataSet XML format.===
:class="structure" : Used for struture arrays ONLY. Contents encoded into a structure array using array notation identical to that described for class="cell". If a structure is size [1 1] then it does not need to use array notation and must not be marked with this class attribute. Instead, the contents of the structure should simply be enclosed within the tag as sub-tags.


===When class is omitted, a single-entry (non-array) structure is assumed.===
:class="dataset"  : Contents will be interpreted as a DataSet Object. Any tags which do not map to valid DataSet Object fields will be ignored. See the DataSet definition for details on valid fields and ENCODEXML for example of DataSet XML format. When class is omitted, a single-entry (non-array) structure is assumed.


==="Size" attribute: Tags of class "numeric", "cell", or "structure" (structure-array only) should also include the attribute size="[...]" which gives the size of the tag's contents. Value for size must be enclosed in square brackets and must be at least two elements long (use [0,0] for empty). For example <myvalue class="numeric" size="[3,4]"> says that the field myvalue will be numeric with 3 rows and 4 columns. Size can be multi-dimensional as needed (size="[2,4,6,2]" implies that the contents of the tag will give a 4-dimensional array of the given sizes)===
:"Size" attribute: Tags of class "numeric", "cell", or "structure" (structure-array only) should also include the attribute size="[...]" which gives the size of the tag's contents. Value for size must be enclosed in square brackets and must be at least two elements long (use [0,0] for empty). For example &lt;myvalue class="numeric" size="[3,4]"&gt; says that the field myvalue will be numeric with 3 rows and 4 columns. Size can be multi-dimensional as needed (size="[2,4,6,2]" implies that the contents of the tag will give a 4-dimensional array of the given sizes)


===If input (filename) is omitted, the user will be prompted for a file name  to read.===
If input (filename) is omitted, the user will be prompted for a file name  to read.


===See Also===
===See Also===


[[encodexml]], [[xclreadr]]
[[encodexml]], [[xclreadr]]

Revision as of 10:14, 9 October 2008

Purpose

Convert XML file to a MATLAB structure.

Synopsis

object = parseXML(filename)

Description

Creates Matlab object from XML file. The format of the file must follow that used by ENCODEXML. Each XML tag will be encoded as a field in a Matlab structure. The top-level tag will be the single field in the top-level of the returned structure and all sub-tags will be sub-fields therein. Contents of those fields can be specified using the following attributes

Tags with the attribute 'class' will be encoded using these rules

class="numeric"  : Contents of tag must be comma-delimited list of values with rows delimited by semicolons. Each row must have the same number of values (equal in length) or an error will result. Multi-way matricies can be encapulated in <tn mode="i"> tags where i is the mode that the enclosed item expands on (i>=3).
class="cell"  : Contents encoded as Matlab cell. Format of contents is same as HTML table tags (<tr> for new row, <td> for new container/column) with the added tag of <tn mode="i"> to describe an multi-dimensional cell (see class="numeric").
class="string"  : Contents encoded as string or padded string array. If multiple row string, each row should be enclosed in <sr> tags.
class="structure" : Used for struture arrays ONLY. Contents encoded into a structure array using array notation identical to that described for class="cell". If a structure is size [1 1] then it does not need to use array notation and must not be marked with this class attribute. Instead, the contents of the structure should simply be enclosed within the tag as sub-tags.
class="dataset"  : Contents will be interpreted as a DataSet Object. Any tags which do not map to valid DataSet Object fields will be ignored. See the DataSet definition for details on valid fields and ENCODEXML for example of DataSet XML format. When class is omitted, a single-entry (non-array) structure is assumed.
"Size" attribute: Tags of class "numeric", "cell", or "structure" (structure-array only) should also include the attribute size="[...]" which gives the size of the tag's contents. Value for size must be enclosed in square brackets and must be at least two elements long (use [0,0] for empty). For example <myvalue class="numeric" size="[3,4]"> says that the field myvalue will be numeric with 3 rows and 4 columns. Size can be multi-dimensional as needed (size="[2,4,6,2]" implies that the contents of the tag will give a 4-dimensional array of the given sizes)

If input (filename) is omitted, the user will be prompted for a file name to read.

See Also

encodexml, xclreadr