Symfony 2 test xml with Symfony\Component\DomCrawler\Crawler



I've got an url that return an xml but I have some problem to extract "link" element.



<rss xmlns:media="http://ift.tt/W3lYmr" version="2.0">
<channel>
<item>
<id>123</id>
<title>my title</title>
<link>
http://example.org
</link>
</item>
<channel>


I need to test it with



Symfony\Component\DomCrawler\Crawler


These are my tests:



$crawler = $this->client->get('/my-feed');

$items = $crawler->filterXPath('//channel/item');
$this->assertGreaterThanOrEqual(1, $items->count()); // ok pass

// ...
$titles = $items->filterXPath('//title')->extract(array('_text'));
$this->assertContains("my title", $titles); // ok pass


// ...
$links = $items->filterXPath('//link')->extract(array('_text'));
$this->assertContains("example.org", $links); // KO!!! don't pass

var_dump($links); // empty string


"link" is a reserved word??


No comments:

Post a Comment