0

I'm loading an xml file comming from a comercial software. If I do print_r($xml) I get something like this:

SimpleXMLElement Object (
 [records] => SimpleXMLElement Object (
     [record] => SimpleXMLElement Object (
         [database] => SomeData
         [ref-type] => SomeData
         [contributors] => SimpleXMLElement Object (
             [authors] => SimpleXMLElement Object (
                 [author] => Array (
                     [0] => SomeData
                     [1] => SomeData
                     [2] => SomeData
                     [3] => SomeData
                     [4] => SomeData
                )
            )
        )
    )
)

I'm extracting desired data with this

$MyNewArray['DataBase'] = (string) $xml->records->record->database;

But can't get to the data when there is an hyphen (there are several fields with an hyphen):

$MyNewArray['ReferenceType'] = (string) $xml->records->record->ref-type;

Does anybody know a solution?

CMArg
  • 1,525
  • 3
  • 13
  • 28
  • @salathe Thanks! I've searched hard before posting the question, but evidently not hard enough. – CMArg Nov 15 '16 at 23:39
  • Just for synthesis: `$MyNewArray['ReferenceType'] = (string) $xml->records->record->{'ref-type'};` – CMArg Nov 16 '16 at 00:08

0 Answers0