Filter XML data (with a namespace) using XPath in PHP?

Php $xml = simplexml_load_file("jobs-rss. Xml"); if(isset($_POST'category') && isset($_POST'region')) { $category = $_POST'category'; $region = $_POST'region'; $html = ''; // Load all jobs foreach($xml->channel->item as $item) { $ns = $item->children('https://itrent-web1. Midlandsco-op.

Com/tlive_webrecruitment/wrd/run/../../webrecRSS. Dtd'); if ($category! = "All" && $category!

= $ns->category) continue; if ($region! = "All" && $region! = $ns->region) continue; $html .

= "" . $item->title .""; $html . = "Reference: " .

$ns->reference .""; $html . = "" . $ns->description .""; $html .

= "Salary: " . $ns->salary .""; $html . = "Region: " .

$ns->region .""; $html . = "Location: " . $ns->location .""; $html .

= "Category: " . $ns->category .""; $html . = "Closing Date: " .

$ns->closingdate .""; $html . = "link . "'>Click here to apply for this job"; } } echo $html;?

By the way, your namespace url https://itrent-web1. Midlandsco-op. Com/tlive_webrecruitment/wrd/run/../../webrecRSS.

Dtd looks a bit strange. I think it would be more clear if you remove the relative '..' stuff and make it like this: https://itrent-web1. Midlandsco-op.Com/tlive_webrecruitment/webrecRSS.

Dtd SimpleXML's child() method will only work with exactly the same URI that is provided in the RSS node's xmlns:job attribute.

Channel->item as $item) { $ns = $item->children('https://itrent-web1. Midlandsco-op.Com/tlive_webrecruitment/wrd/run/../../webrecRSS. Dtd'); if ($category!

= "All" && $category! = $ns->category) continue; if ($region! = "All" && $region!

= $ns->region) continue; $html . = "" . $item->title .

""; $html . = "Reference: " . $ns->reference .

""; $html . = "" . $ns->description .

""; $html . = "Salary: " . $ns->salary .

""; $html . = "Region: " . $ns->region .

""; $html . = "Location: " . $ns->location .

""; $html . = "Category: " . $ns->category .

""; $html . = "Closing Date: " . $ns->closingdate .

""; $html . = "link . "'>Click here to apply for this job"; } } echo $html;?

> By the way, your namespace url " https://itrent-web1. Midlandsco-op. Com/tlive_webrecruitment/wrd/run/../../webrecRSS.

Dtd " looks a bit strange. I think it would be more clear if you remove the relative '..' stuff and make it like this: https://itrent-web1. Midlandsco-op.

Com/tlive_webrecruitment/webrecRSS. Dtd SimpleXML's child() method will only work with exactly the same URI that is provided in the RSS node's xmlns:job attribute.

Imi, The $category and $region variables will be populated by POST from the form. I want to filter the XMl and return only those items that match - e.g. If the category is Funeral, only return s where is Funeral. – Brett Aug 12 at 8:34.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions