Jump to content

Recommended Posts

After trying this pice of code, i get mixed results. I get the string correct, but the IF statement fails for some reason? Here's the code, then the output:

$xml2 = new SimpleXMLElement("../sitemap.xml",null,true);
foreach ($xml2->url as $loc){
if ($loc->loc == "http://LinuxIntro.com?action=".$qx1[0]."&name=".$_GET['name']){
	echo "I found IT!<br/>";
}else{
	echo "Not it!<br/>";
	echo "http://LinuxIntro.com?action=".$qx1[0]."&name=".$_GET['name']."<br/>";
	echo $loc->loc . "<br/>";
}
}

Which returns:

Not it!
http://LinuxIntro.com?action=ShowContent&name=aaaaaaaaaaaaaa
http://LinuxIntro.com/
Not it!
http://LinuxIntro.com?action=ShowContent&name=aaaaaaaaaaaaaa
http://LinuxIntro.com?action=ShowContent&name=aaaaaaaaaaaaaa

What i am attempting to accomplish, is to remove a page from my sitemap, when i delete it from the database. I have the opposite effect in place already; when i create a new page via my admin console i wrote, it adds that page to my sitemap. Now i need the reverse done: when i delete a page from the DB, it is also removed from the sitemap.

 

===EDIT===

Also, i guess, just for clarity, i should add the contents of my xml file:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">

<url>
  <loc>http://LinuxIntro.com/</loc>
  <changefreq>daily</changefreq>
  <priority>0.3</priority>
</url>


<url>
<loc>http://LinuxIntro.com?action=ShowContent&name=aaaaaaaaaaaaaa</loc>
<changefreq>daily</changefreq>
<priority>0.3</priority>
</url>

</urlset>

 

Thanx

Link to comment
https://forums.phpfreaks.com/topic/83181-simplexml-removechil/#findComment-423120
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.