0

I have parsed an xml node into my MATLAB project with the following information:

      Name: '#text'
Attributes: []
      Data: '500'
  Children: []

I can easily acess the name of the node using node.getNodeName.

Now I want to read the data out of this node, but I don't get MATLAB to do this.

I tried:

dataString=node.getData;

and

dataString=char(node.getData);

In both cases I got this error:

Argument to dynamic structure reference must evaluate to a valid field name.

What went wrong with my code?

  • What error message do you get? – Daniel Jan 19 '16 at 17:25
  • Sorry, If forgot to post. The **error** is: `Argument to dynamic structure reference must evaluate to a valid field name.` – fritzleone Jan 20 '16 at 15:07
  • That error message surprises me, because your code does not contain any dynamic field names. Can you upload an example file and the code you are using? – Daniel Jan 20 '16 at 15:16
  • @Daniel I have my example files [here](https://www.dropbox.com/sh/a28rz22w70q1ol3/AACpv5zUkz2a1rKj63m_YGbza?dl=0). One xml-file to parse and the m-file. The code structure is from [here](http://de.mathworks.com/help/matlab/ref/xmlread.html). – fritzleone Jan 20 '16 at 15:42

1 Answers1

0

To precise my comments, your question did not contain any dynamic field names, but your code does!

The relevant code lines are the two lines

struct1.(theChild.getNodeName)=char(nameChild.getData);

Here theChild.getNodeName is of type java.lang.String and not of type char. Use this line instead:

struct1.(char(theChild.getNodeName))=char(nameChild.getData);
Daniel
  • 36,610
  • 3
  • 36
  • 69