How to convert the data entry where rows have uneven entry within xml into a table?

1 次查看(过去 30 天)
While running the code on this data the centroid which is a variable has 385 entries, in which there are three variables. However on some rows there are four variables example on row number 12. There is entry of variable with name 1event. The loop stops at row 12 and give a error mentioned in the above picture. You can also see ME exception.
Thanks for your consideration.

回答(1 个)

Divyanshu
Divyanshu 2024-2-27
Hi Praful,
The reason you are getting this error 'All tables being vertically concatenated must have same number of variables' is because table is a structured data and cannot have different number of columns in different rows.
A possible workaround can be :
  • Create a table with number of columns equal to maximum variables of all the entries of XML file.
  • Now for each item on xml file create a row and fill the variables/columns with values.
  • If the current item is having less variables than maximum, you can fill those columns with '-'.
Hope it helps!

类别

Help CenterFile Exchange 中查找有关 Structured Data and XML Documents 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by