I'm currently working with Google RSS feeds. Following is my xml response.
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<title>Example</title>
<link>https://www.example.com</link>
<item>
<g:id>25</g:id>
<g:title>Item 1</g:title>
<g:description>Lorem Ipsum</g:description>
</item>
<item>
<g:id>26</g:id>
<g:title>Item 2</g:title>
<g:description>Lorem Ipsum</g:description>
</item>
</channel>
</rss>
Now, I want to delete Item having g:id 25. Please guide how to delete that node from xml code. Thanks in advance. Tried using following code but $nodelist returning 0 length.
$dom = new DomDocument;
$id = 25;
$productId = $id;
$dom->loadXML($filecontent);
// Locate the old product node to modify
$xpath = new DOMXpath($dom);
$nodelist = $xpath->query("/channel/item/g:id={$productId}");
$oldnode = $nodelist->item(0);
// Remove
$oldnode->removeChild($oldnode);
echo $dom->saveXML();//Done output XML