PHP 초보자를 도울 수 있기를 희망합니다 (C#을 보여주고 괜찮습니다!).PHP에서 XPath를 사용하여 XML 데이터 (네임 스페이스 사용)를 필터링하십시오.
PHP 변수를 기반으로 XML 데이터를 필터링하고 싶습니다.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="2.0" xmlns:job="https://my/namespace/URL.dtd">
<channel>
<title>search form results</title>
<link></link>
<description></description>
<item>
<title>TEST - Funeral Administrator</title>
<link> https://itrent-web1.midlandsco-op.com/tlive_webrecruitment/wrd/run//ETREC107GF.open?VACANCY_ID%3d3416494H67&WVID=6405682s15</link>
<guid> https://itrent-web1.midlandsco-op.com/tlive_webrecruitment/wrd/run//ETREC107GF.open?VACANCY_ID%3d3416494H67&WVID=6405682s15</guid>
<description><![CDATA[<b>Reference:</b> REQ000072<br /><b>Description:</b> Applications are invited for a part time, 22.5 hours per week, Funeral Administratorwhich will be based at West Bromwich Funeral Home within the West Region. Working as part of a team, duties will include co-ordinating funeral arrangements according to the clients' wishes, compiling the required administration, offering advice on the full range of services available and liaising with all relevant authorities and internal contacts. You will also be expected to assist families who wish to pay their last respects.You will be required to administer petty cash, cheque reconciliation forms, banking and purchase ledger. Other general office duties include answering the telephones, basic computer input and filing will also be key duties of this role.Applicants will have good inter-personal skills, driving licence and must also have good keyboard skills and computer literate. A flexible approach to working hours is also required.<br /><b>Region:</b> Birmingham<br /><b>Location:</b> West Bromwich<br /><b>Salary:</b> from £7.31 per hour<br /><b>Package:</b> n/a ]]></description>
<job:description>Applications are invited for a part time, 22.5 hours per week, Funeral Administratorwhich will be based at West Bromwich Funeral Home within the West Region. Working as part of a team, duties will include co-ordinating funeral arrangements according to the clients' wishes, compiling the required administration, offering advice on the full range of services available and liaising with all relevant authorities and internal contacts. You will also be expected to assist families who wish to pay their last respects.You will be required to administer petty cash, cheque reconciliation forms, banking and purchase ledger. Other general office duties include answering the telephones, basic computer input and filing will also be key duties of this role.Applicants will have good inter-personal skills, driving licence and must also have good keyboard skills and computer literate. A flexible approach to working hours is also required.</job:description>
<job:reference>REQ000072</job:reference>
<job:salary>from £7.31 per hour</job:salary>
<job:salaryval>14800</job:salaryval>
<job:minsalary>14000</job:minsalary>
<job:maxsalary>16000</job:maxsalary>
<job:category>Funeral</job:category>
<about>Mon, 8 Aug 2011 00:00:00 GMT</about>
<job:region>Birmingham</job:region>
<job:location>West Bromwich</job:location>
<job:package>n/a</job:package>
<pubDate>Mon, 25 Jul 2011 00:00:00 GMT</pubDate>
</item>
... etc - other <item> nodes follow
은 내가 이러한 변수에 따라 내 XML을 필터링 할 수 있도록하려는
$category = $_POST['category'];
$region = $_POST['region'];
에서 2 개 PHP 변수를 얻을 수 있지만, 어떻게 알아낼 수 없습니다 : 여기 내 XML 파일의 컷입니다 그것. XML의 region 및 category 노드 앞에는 네임 스페이스가 있습니다.
여기에 어떤 도움을 크게 감상 할 수<?php
$xml = simplexml_load_file("jobs-rss.xml");
if(isset($_POST['category']) && isset($_POST['region']))
{
$category = $_POST['category'];
$region = $_POST['region'];
$html = '';
if($category == "All" && $region == "All")
{
// Load all jobs
foreach($xml->channel->item as $item){
$ns = $item->children('https://itrent-web1.midlandsco-op.com/tlive_webrecruitment/wrd/run/../../webrecRSS.dtd');
$html .= "<h2>" . $item->title . "</h2>";
$html .= "<p><strong>Reference: </strong>" . $ns->reference . "</p>";
$html .= "<p>" . $ns->description . "</p>";
$html .= "<p><strong>Salary: </strong>" . $ns->salary . "</p>";
$html .= "<p><strong>Region: </strong>" . $ns->region . "</p>";
$html .= "<p><strong>Location: </strong>" . $ns->location . "</p>";
$html .= "<p><strong>Category: </strong>" . $ns->category . "</p>";
$html .= "<p><strong>Closing Date: </strong>" . $ns->closingdate . "</p>";
$html .= "<p><a href='" . $item->link . "'>Click here to apply for this job</a></p>";
}
}
else
{
// Filter my XML here based on a combination of the $category and $region varaibles
}
}
echo $html;
?>
내 (아주 기본적인 그렇게 웃지 않는다) PHP입니다.
덕분에, 브렛 필터링함으로써
"필터"란 무엇을 의미합니까? –