/** * Gets the DOM document of this element * @return DOMDocument */ public function toDom() { $dom = new DOMDocument('1.0', 'utf-8'); $contactItem = $dom->createElementNS(Client::SCHEMA_TYPES, self::NAME); if ($this->FileAs) { $contactItem->appendChild($dom->createElement(self::ELEMENT_FILE_AS, htmlspecialchars($this->FileAs))); } if ($this->GivenName) { $contactItem->appendChild($dom->createElement(self::ELEMENT_GIVEN_NAME, htmlspecialchars($this->GivenName))); } if ($this->CompanyName) { $contactItem->appendChild($dom->createElement(self::ELEMENT_COMPANY_NAME, htmlspecialchars($this->CompanyName))); } if ($this->EmailAddresses) { $emailAddressesDom = $this->EmailAddresses->toDom(); $emailAddressesElement = $dom->importNode($emailAddressesDom->documentElement, true); $contactItem->appendChild($emailAddressesElement); } if ($this->PhysicalAddresses) { $physicalAddressesDom = $this->PhysicalAddresses->toDom(); $physicalAddressesElement = $dom->importNode($physicalAddressesDom->documentElement, true); $contactItem->appendChild($physicalAddressesElement); } if ($this->PhoneNumbers) { $phoneNumbersDom = $this->PhoneNumbers->toDom(); $phoneNumbersElement = $dom->importNode($phoneNumbersDom->documentElement, true); $contactItem->appendChild($phoneNumbersElement); } if ($this->JobTitle) { $contactItem->appendChild($dom->createElement(self::ELEMENT_JOB_TITLE, htmlspecialchars($this->JobTitle))); } if ($this->Surname) { $contactItem->appendChild($dom->createElement(self::ELEMENT_SURNAME, htmlspecialchars($this->Surname))); } $dom->appendChild($contactItem); return $dom; }
/** * Gets the XML of the EmailAddresses element * @param EmailAddressDictionary $dictionary * @return string */ public static function toXml(EmailAddressDictionary $dictionary) { $dom = $dictionary->toDom(); return $dom->saveXML(); }