Delete xml node && data in the case node the same data?
<pre><code>$xml = '&lt;books&gt;    
            &lt;book&gt;
                &lt;qty&gt;12&lt;/qty&gt;
                &lt;title&gt;C++&lt;/title&gt;
            &lt;/book&gt;
            &lt;book&gt;
                &lt;qty&gt;21&lt;/qty&gt;
                &lt;title&gt;PHP&lt;/title&gt;
            &lt;/book&gt;    
        &lt;/books&gt;    
        &lt;books&gt;        
            &lt;book&gt;  
            &lt;qty&gt;21&lt;/qty&gt;
            &lt;title&gt;JAVA&lt;/title&gt;
            &lt;/book&gt;    
        &lt;/books&gt;';


$str = '&lt;content&gt;'.$xml.'&lt;/content&gt;';

$doc = new DOMDOcument;
$doc-&gt;loadxml($str);

$xpath = new DOMXpath($doc);

$arr = array(
    array('12;C++', '21;PHP')
);

# Remove elements based on qty and title
foreach($arr as $items) {
    foreach($items as $item) {
        list($qty, $title) = explode(';', $item);
        foreach($xpath-&gt;query('/content/books/book[title="'.$title.'"][qty="'.$qty.'"]') as $book) {
            $book-&gt;parentNode-&gt;removeChild($book);
        }
    }
}

# Remove empty &lt;books&gt;
foreach($xpath-&gt;query('books[count(book)=0]') as $empty) {
    $empty-&gt;parentNode-&gt;removeChild($empty);
}
header('Content-type: text/xml');
echo $doc-&gt;savexml();
</code></pre>

<p>OUTPUT:</p>

<pre><code>&lt;content&gt;
    &lt;books&gt;
        &lt;book&gt;
            &lt;qty&gt;21&lt;/qty&gt;
            &lt;title&gt;JAVA&lt;/title&gt;
        &lt;/book&gt;
    &lt;/books&gt;
&lt;/content&gt;
</code></pre>

<p>But if the xml contain the same data like this:</p>

<pre><code>$xml = '&lt;books&gt;    
            &lt;book&gt;
                &lt;qty&gt;12&lt;/qty&gt;
                &lt;title&gt;C++&lt;/title&gt;
            &lt;/book&gt;
            &lt;book&gt;
                &lt;qty&gt;21&lt;/qty&gt;
                &lt;title&gt;PHP&lt;/title&gt;
            &lt;/book&gt;    
        &lt;/books&gt;    
        &lt;books&gt;        
            &lt;book&gt;  
                &lt;qty&gt;21&lt;/qty&gt;
                &lt;title&gt;PHP&lt;/title&gt; &lt;!-- here the same data--&gt;
            &lt;/book&gt;    
        &lt;/books&gt;';
</code></pre>

<p>it should get output something like this:</p>

<pre><code>&lt;content&gt;
    &lt;books&gt;
        &lt;book&gt;
            &lt;qty&gt;21&lt;/qty&gt;
            &lt;title&gt;PHP&lt;/title&gt;
        &lt;/book&gt;
    &lt;/books&gt;
&lt;/content&gt;
</code></pre>

<p>Why it delete all of my nodes ?and I got  </p>

<pre><code>&lt;content&gt;
&lt;/content&gt;
</code></pre>
