Help: How to model a XML response?

Created on 8 April 2020, over 4 years ago
Updated 4 May 2023, over 1 year ago

Hi guys.
First of all, thanks for all the work on this amazing module.

I am having a hard time figuring out how to map a XML response to a response Model.
Could anyone provide me with the equivalent Model (yml) for the following XML response:

<?xml version="1.0" encoding="utf-8" ?>
<response>
  <status>
    <scode>0</scode>
    <message>OK</message>
  </status>
  <data>
    <api _name="AccesscodeBasicInfo">
      <AccessCode>BAR_BAZ_FOO</AccessCode>
      <AccountCode>FOOBAR</AccountCode>
      <CreateTime>2020-03-24 06:42:45</CreateTime>
      <ExpireTime>2020-06-21 06:42:45</ExpireTime>
      <Expired>false</Expired>
    </api>
  </data>
 </response>

Thanks in advance!
Heitor.

πŸ’¬ Support request
Status

Closed: works as designed

Version

2.0

Component

Code

Created by

πŸ‡§πŸ‡·Brazil halth Brazil

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States MrAdamJohn

    Thanks folks - we should consider move the handling of XML responses into the docs, perhaps.

    Extending the OP question just a bit - in the original XML response on line 8;
    <api _name="AccesscodeBasicInfo">

    Can the `api` tag `_name` attribute value be obtained?
    In this case, "AccesscodeBasicInfo" is the value for the given `_name` attribute of the `api` tag.

    The response I am getting from one of my APIs has attribute values that I need, and so far not finding a means to obtain that value using this approach.

Production build 0.71.5 2024