Example #1
0
 /**
  * Converts XML formatted publisher to Services_Gnip_Publisher object.
  * 
  * @param string $xml XML data
  * @return object Services_Gnip_Publisher
  */
 function fromXML($xml)
 {
     $xml_element = new SimpleXMLElement($xml);
     if ($xml_element->getName() != 'publisher') {
         throw new Exception("expected publisher");
     }
     $publisher = new Services_Gnip_Publisher($xml_element["name"], array());
     $supportedRuleTypes = $xml_element->supportedRuleTypes;
     if ($supportedRuleTypes) {
         foreach ($supportedRuleTypes->children() as $rule_type) {
             $publisher->supported_rule_types[] = Services_Gnip_Rule_Type::fromXML($rule_type->asXML());
         }
     }
     return $publisher;
 }
Example #2
0
 function testFromXml()
 {
     $xml = '<type>actor</type>';
     $rule_type = Services_Gnip_Rule_Type::fromXml($xml);
     $this->assertEquals("actor", $rule_type->type);
 }