Ejemplo n.º 1
0
 /**
  * Extracts the title from the given piece of XML, i.e. extracting the
  * first <head> node converting it to plaintext.
  *
  * @param $xml
  *
  * @return string
  */
 public function extractTitle($xml)
 {
     $sx = new \SimpleXMLElement($xml);
     if (!isset($sx->head[0])) {
         return '';
     }
     $headXml = $sx->head[0]->asXml();
     return $this->plaintextConverter->convert($headXml);
 }
Ejemplo n.º 2
0
 /**
  * @test
  */
 public function plaintextConversionWorks()
 {
     $pc = new PlaintextConverter();
     $actual = $pc->convert('<p>The characters &lt; &gt; &amp; <em>must</em> be converted.</p>');
     $this->assertSame('The characters < > & must be converted.', $actual);
 }