MATLAB Answers

0

How to write xml file

Asked by SAMEER ahamed on 16 Feb 2014
Latest activity Commented on by SAMEER ahamed on 22 Feb 2014
Hi,
I want to write XMl file(Create XML File), based on continuous coordinates values.
Step 1 : My Continuous Values are having .
Example :I want to create xml file like:
if true
% code
<id>hello-1</id>
<matrix class="vector">
<vector>
<int>3</int>
<int>-99</int>
<int>-6</int>
<int>79</int>
<int>-195</int>
<int>11</int>
<int>197</int>
<int>8</int>
</vector>
<vector>
<int>4</int>
<int>-99</int>
<int>-5</int>
<int>79</int>
<int>-195</int>
<int>12</int>
<int>196</int>
<int>9</int>
</vector>
<vector>
<int>2</int>
<int>-99</int>
<int>-6</int>
<int>79</int>
<int>-192</int>
<int>12</int>
<int>197</int>
<int>6</int>
</vector>
end

  2 Comments

I have tried to implement below code like , but i got error here matrix class="vector" how i can initialize ?
if true
% code
docNode = com.mathworks.xml.XMLUtils.createDocument('lipreading');
docRootNode = docNode.getDocumentElement;
thisElement = docNode.createElement('id');
thisElement.appendChild(docNode.createTextNode(combinedStr));
docRootNode.appendChild(thisElement);
matrix_thisElement = docNode.createElement('matrix class="vector"');
vector_thisElement = docNode.createElement('vector');
left_int_thisElement = docNode.createElement('int');
left_int_value_thisElement = docNode.createElement(handles.upper_distance_X);
docRootNode.appendChild(left_int_value_thisElement);
docRootNode.appendChild(left_int_thisElement);
docRootNode.appendChild(vector_thisElement);
docRootNode.appendChild(matrix_thisElement);
xmlFileName = ['tempname','.xml'];
xmlwrite(xmlFileName,docNode);
edit(xmlFileName);
end
Hi,
I am new for matlab , now i have 10 frames video file , each frame values i need to stored in xml file ?
I have Matlab Code Below like :
for i=1:10
matrix{1,i}=[leftx,lefty,rightx,righty,uppertx,uppery,bottomx,bottomy];%1-by-8 matrix
end
Below format i want to stored values please let me know how i can format like ?
example :
<reading>
<id>id1</id>
<matrix class="vector">
<vector>
<int>2</int>
<int>1</int>
<int>44</int>
<int>45</int>
<int>42</int>
<int>24</int>
<int>14</int>
<int>84</int>
</vector>
<vector>
<int>7</int>
<int>31</int>
<int>674</int>
<int>455</int>
<int>2</int>
<int>24</int>
<int>4</int>
<int>84</int>
</vector>
</matrix>
</reading>

Sign in to comment.

Tags

No tags entered yet.

Products

0 Answers