You are here

public function RSSSimpleXMLElement::appendXml in Facebook Instant Articles 7

Same name and namespace in other branches
  1. 7.2 modules/fb_instant_articles_rss/src/RSSSimpleXMLElement.php \Drupal\fb_instant_articles_rss\RSSSimpleXMLElement::appendXml()

Adds SimpleXMLElement code into a SimpleXMLElement.

Parameters

\SimpleXMLElement $append: XMLElement to append to.

File

modules/fb_instant_articles_rss/src/RSSSimpleXMLElement.php, line 54
Contains \Drupal\fb_instant_articles_rss\RSSSimpleXMLElement.

Class

RSSSimpleXMLElement
Extension for SimpleXMLElement.

Namespace

Drupal\fb_instant_articles_rss

Code

public function appendXml(\SimpleXMLElement $append) {
  if ($append) {
    if (strlen(trim((string) $append)) == 0) {
      $xml = $this
        ->addChild($append
        ->getName());
      foreach ($append
        ->children() as $child) {
        $xml
          ->appendXml($child);
      }
    }
    else {
      $xml = $this
        ->addChild($append
        ->getName(), (string) $append);
    }
    foreach ($append
      ->attributes() as $n => $v) {
      $xml
        ->addAttribute($n, $v);
    }
  }
}