MATLAB 7.10 (R2010a) returns Null when using getElementByID

2 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2010 年 4 月 26 日
編集済み: MathWorks Support Team 2018 年 6 月 4 日
I'm reading an xml file using Matlab's xmlread-function. For some reason searching for elements by id doesn't work for me. Here's an example:
File 'test.xml':
<?xml version="1.0" encoding="utf-8"?>
<Measurements>
<Setup id="a">
<myval>3</myval>
</Setup>
<Setup id="b">
<myval>4</myval>
</Setup>
</Measurements>
>> dom = xmlread('test.xml');
>> dom.getElementsByTagName('Setup')
ans =
org.apache.xerces.dom.DeepNodeListImpl@3e906
>> dom.getElementById('a')
ans =
[]
The first call, searching for elements by tagname works fine, but not searching by id. This should work, according to https://www.w3schools.com/jsref/met_document_getelementbyid.asp
What's going on here?

採用された回答

MathWorks Support Team
MathWorks Support Team 2018 年 6 月 4 日
編集済み: MathWorks Support Team 2018 年 6 月 4 日
In MATLAB 7.10 (R2010a), the usage of getElementByID is the same as standard DOM implementation. Having an attribute with name "id" is not of type ID by default. Typically, the element must be inserted in order to be accessed by getElementByID.
Additional information is available here:

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructured Data and XML Documents についてさらに検索

製品


リリース

R2010a

Community Treasure Hunt

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

Start Hunting!

Translated by