0

我想将 XML 文档转换为有用的 matlab 对象,该对象可以遍历节点以获取信息。XML 文档看起来有点复杂,如下所示:

      <?xml version="1.0" encoding="utf-8"?>

<!-- SDMX-ML from Gesmes/TS Suite -->
<!-- @(#)$Id: SDMXMLWriter.java,v 1.21 2013/03/08 09:44:17 stahlma Exp $ -->

<MessageGroup xmlns="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message https://stats.ecb.europa.eu/stats/vocabulary/sdmx/2.0/SDMXMessage.xsd">
    <Header>
        <ID>IREF153799</ID>
        <Test>false</Test>
        <Name>daily data 20131119T000000</Name>
        <Prepared>2013-11-20T08:19:00+01:00</Prepared>
        <Sender id="4F0"/>
        <Receiver id="4F"/>
        <KeyFamilyRef>ECB_FMD2</KeyFamilyRef>
        <KeyFamilyAgency>ECB</KeyFamilyAgency>
        <DataSetID>ECB_YC</DataSetID>
    </Header>
    <DataSet action="Replace" xmlns="http://www.ecb.int/vocabulary/stats/fmd/2" xsi:schemaLocation="http://www.ecb.int/vocabulary/stats/fmd/2 https://www.ecb.europa.eu/stats/sdmx/fmd/2/structure/2007-06-13/sdmx-compact.xsd">
        <Group REF_AREA="U2" CURRENCY="EUR" PROVIDER_FM="4F" INSTRUMENT_FM="G_N_A" PROVIDER_FM_ID="SV_C_YM" DATA_TYPE_FM="BETA0" DECIMALS="6" TITLE_COMPL="Euro area (changing composition) - Government bond, nominal, all issuers whose rating is triple A - Svensson model - continuous compounding - yield error minimisation - Yield curve parameters, Beta 0 - Euro, provided by ECB" UNIT="PURE_NUMB" UNIT_MULT="0"/>
        <Series FREQ="B" REF_AREA="U2" CURRENCY="EUR" PROVIDER_FM="4F" INSTRUMENT_FM="G_N_A" PROVIDER_FM_ID="SV_C_YM" DATA_TYPE_FM="BETA0" TIME_FORMAT="P1D" COLLECTION="E">
            <Obs TIME_PERIOD="2013-11-19" OBS_VALUE="2.02776" OBS_STATUS="A" OBS_CONF="F"/>
        </Series>
        <Group REF_AREA="U2" CURRENCY="EUR" PROVIDER_FM="4F" INSTRUMENT_FM="G_N_A" PROVIDER_FM_ID="SV_C_YM"
...

DATA_TYPE_FM="PY_30Y" TIME_FORMAT="P1D" COLLECTION="E">
            <Obs TIME_PERIOD="2013-11-19" OBS_VALUE="3.723442" OBS_STATUS="A" OBS_CONF="F"/>
        </Series>
    </DataSet>
</MessageGroup>

当我使用 xmlread('filename.xml') 并编写 xml.getElementsByTagName('Header') 我得到:

ans =

org.apache.xerces.dom.DeepNodeListImpl@57a08efb

我将不胜感激任何帮助。

提前致谢!

4

0 回答 0