I am trying to get all the title
elements and save them in an array.
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mylist>
<element>
<id>1</id>
<title>Example 1</title>
<status>2</status>
<my_status>2</my_status>
</element>
<element>
<id>2</id>
<title>Example 2</title>
<status>1</status>
<my_status>1</my_status>
</element>
<element>
<id>3</id>
<title>Example 3</title>
<status>2</status>
<my_status>6</my_status>
</element>
<element>
<id>4</id>
<title>Example 4</title>
<status>3</status>
<my_status>6</my_status>
</element>
<element>
<id>5</id>
<title>Example 5</title>
<status>1</status>
<my_status>6</my_status>
</element>
</mylist>
PHP:
$crawler = new Crawler();
$crawler->addXmlContent($data);
$result = $crawler->filterXPath('/mylist/element[not(status=3) and my_status=6]/title/text()');
The elements nodes needs to satisfy some conditions, so calling $result->count()
should print 2
(Example 3 & Example 5), but it prints 0.