1

私はこれを使おうとします:

xml2struct

このxmlを使用する場合:

<XMLname attrib1="Some value">
    <Element>Some text</Element>
    <DifferentElement attrib2="2">Some more text</DifferentElement>
    <DifferentElement attrib3="2" attrib4="1">Even more text</DifferentElement>
</XMLname>

構造体を作成できます:

test = xml2struct('C:\bla\bla.xml');

(class(test)でテストしました)

次のようになります。

テスト=

      Name: 'XMLname'
Attributes: [1x1 struct]
      Data: ''
  Children: [1x7 struct]

しかし、私はアクセスできません:

test.XMLname.Element.Text

私は得る:

??? 存在しないフィールド'XMLname'への参照。

何か案は?

4

2 に答える 2

1

R2010bで試してみたところ、正常に動作します

>> data=xml2struct('bla.xml')
data = 
    XMLname: [1x1 struct]

>> data.XMLname
ans = 
             Element: [1x1 struct]
    DifferentElement: {[1x1 struct]  [1x1 struct]}
          Attributes: [1x1 struct]

matlabパスのどこかに古いバージョンのxml2structがある可能性はありますか?which xml2structあなたが期待する道をあなたに与えることを確認してください

于 2012-06-20T15:41:07.547 に答える
1

あなたの質問を見ると、このような構造が見えます

test =

      Name: 'XMLname'
Attributes: [1x1 struct]
      Data: ''
  Children: [1x7 struct]

構造の存在しないコンポーネントを読み取ろうとします

test.XMLname.Element.Text

つまり、構造には。testという名前のコンポーネントがありませんXMLname

私は明らかな何かを見逃していますか、それともあなたですか?

于 2012-06-20T15:47:51.223 に答える