0

I want to convert a XML document to a useful matlab object which can iterate through the nodes to fetch information. The XML document is a bit complicated look like this:

      <?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>

When i use xmlread('filename.xml') and write xml.getElementsByTagName('Header') i get:

ans =

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

I would appreciate any help.

Thanks in advance!

Christophe Roussy
  • 16,299
  • 4
  • 85
  • 85
  • This is what `xmlread` and `getElementsByTagName` are supposed to do. Do you want to parse the full xml or just get some certain values/tags? – sebastian Nov 21 '13 at 10:21
  • This should put you on the right track: http://www.mathworks.com/matlabcentral/answers/95747, http://blogs.mathworks.com/community/2010/11/01/xml-and-matlab-navigating-a-tree/, http://www.mathworks.com/help/matlab/import_export/importing-xml-documents.html – Amro Nov 21 '13 at 10:52
  • or you could use one of the many XML toolboxes on the File Exchange like this one: http://www.mathworks.com/matlabcentral/fileexchange/12907-xmliotools – Amro Nov 21 '13 at 10:58

0 Answers0