Example #1
0
 public function testGetTextFromDOMNodeWithMultipleCallbacks()
 {
     $doc = new DOMDocument();
     $doc->loadXML('<r>foo <u>bar</u> <u>baz</u> zoo <a>arf</a> final</r>');
     $filter1 = new BoldFilterNode('u');
     $filter2 = new FilterNode('a');
     $this->assertEquals('foo <b>bar</b> <b>baz</b> zoo arf final', DOMNodeHelper::get_text($doc->documentElement, array(XML_ELEMENT_NODE => array($filter1, $filter2))));
 }
 /** @brief Retrieves array of texts from XML node.
  *
  * @remark @c afs prefix should never be used in provided XPath.
  *
  * @param $path [in] XPath to apply (default=null, retrieve all content as
  *        text).
  * @param $nsmap [in] prefix/uri mapping to use along with provided XPath.
  * @param $callbacks [in] list of callbacks to emphase text when highlight
  *        of client data is activated or when client data text is truncated.
  *        It should be list of @a FilterNode type
  *        (default=null, default instances of @a FilterNode are used).
  *
  * @return text of first specific node(s) depending on parameters.
  *
  * @exception AfsInvalidQueryException when provided XPath is invalid.
  * @exception AfsNoResultException when provided XPath returns no value/node.
  */
 public function get_values($path = null, $nsmap = array(), $callbacks = null)
 {
     if (is_null($path)) {
         return array($this->contents);
     } else {
         $items = $this->apply_xpath($path, $nsmap);
         $named_callbacks = $this->update_callbacks(is_null($callbacks) ? array() : $callbacks);
         $result = array();
         foreach ($items as $item) {
             $result[] = DOMNodeHelper::get_text($item, $named_callbacks);
         }
         return $result;
     }
 }