You are here

private function WSDecoderXML::decodeXml in Web Service Data 2.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/WSDecoder/WSDecoderXML.php \Drupal\wsdata\Plugin\WSDecoder\WSDecoderXML::decodeXml()

XML Parsing helper function, converts nested XML objects into arrays.

1 call to WSDecoderXML::decodeXml()
WSDecoderXML::decode in src/Plugin/WSDecoder/WSDecoderXML.php
Decode the web service response string.

File

src/Plugin/WSDecoder/WSDecoderXML.php, line 55

Class

WSDecoderXML
XML Decoder.

Namespace

Drupal\wsdata\Plugin\WSDecoder

Code

private function decodeXml($value) {
  if (is_object($value) and get_class($value)) {
    $value = get_object_vars($value);
    foreach ($value as $k => $v) {
      $value[$k] = $this
        ->decodeXml($v);
    }
  }
  elseif (is_array($value)) {
    foreach ($value as $key => $xml) {
      $value[$key] = $this
        ->decodeXml($xml);
    }
  }
  return $value;
}