0

I'm making an API call and the response is giving me XML:

            <custom_column name="field1"/>
            <custom_column name="field2"/>
            <custom_column name="Age>23</custom_column>

So in the response, the only element that has a value is the elemnt where name="Age".

When I turn that XML into an object via simplexml_load_string($strXML), I get the following:

              [7] => SimpleXMLElement Object
                            (
                                [@attributes] => Array
                                    (
                                        [name] => field1
                                    )

                            )

                        [8] => SimpleXMLElement Object
                            (
                                [@attributes] => Array
                                    (
                                        [name] => field2
                                    )

                            )

                        [9] => 23      

The @attributes are getting stripped only when there is a value present inside the element.

This is not what I'm after because I'm creating a sync between two platforms and have no field name to leverage in the mapping process with what is being returned.

Jordan
  • 1
  • It may not show but it's there see this https://stackoverflow.com/a/12437393/6160662 – Vinay Nov 09 '17 at 03:11
  • I followed that thread and used the function that was referenced, but the return doesn't appear to be anything I can actually work with, just shows that the values are actually there. Any idea on how to best get it in a format that I can drill down into, leveraging "age" as the key and "23" as the value? – Jordan Nov 09 '17 at 19:13

0 Answers0