我有一个大杂烩,它深入到 iframe 中以从 XML 结果中检索属性。(我这样做是为了避免从这个异地服务器获取数据所涉及的十亿个其他问题。)
<?php
$link = mysqli_connect(//ALL THE CONNECTS!);
mysqli_select_db(//THE_DB, $link);
$query = "SELECT * FROM jos_mls AS mls
INNER JOIN jos_activeagents AS active ON mls.MSTLISTBRD = active.AGENTUID
LIMIT 10;";
$result = mysqli_query($query);
$array = array();
$index = 0;
while($row = mysqli_fetch_array($result))
{
$array[$index] = $row;
$index++;
}
foreach ($array as $key => $value) {
$mls = $value[1];
$street = $value[5].' '.$value[6];
$city = $value[9];
$state = $value[10];
$zip = $value[11];
$url = "http://eligibility.sc.egov.usda.gov/eligibility/eligibilityservice?eligibilityType=Property&requestString=<?xml version='1.0'?><Eligibility xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='/var/lib/tomcat5/webapps/eligibility/Eligibilitywsdl.xsd'><PropertyRequest StreetAddress1='".$street."' StreetAddress2='' StreetAddress3='' City='".$city."' State='".$state."' County='' Zip='".$zip."' Program='RBS'></PropertyRequest></Eligibility>";
$frame = '<iframe class="frame" mls="'.$mls.'" style="width: 10px; height: 10px;" src="'.$url.'"></iframe>';
echo $frame;
}
mysql_close($link);
?>
<div id="test"></div>
<script type="text/javascript">
$(document).ready(function(){
$('.frame').each(function(){
var mls = $(this).attr('mls'),
usda = $(this).contents().find('Property').attr('Eligibility');
$('#test').append(mls+' '+usda+'<br/>');
});
});
</script>
iframe 中的数据如下所示...
<?xml version="1.0" encoding="UTF-8"?>
<Eligibility xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Adjusted AnnualIncome="" TotalDeduction="" AdjustedIncome="" ElderlyDeduction="" YoungDeduction="">
</Adjusted>
<Section502Guaranted MaximumAdjusted="" Eligible="">
</Section502Guaranted>
<Section502Direct MaximumAdjusted="" Eligible="">
</Section502Direct>
<Property Eligibility="InEligible" MapURL="http://rdgdwe.sc.egov.usda.gov/eligibilitymaps/index.jsp?app=RBSIELG&ADDRESS=7865 ILLINOIS CASEYVILLE&STATE=IL&ZIP=62232" />
<ErrorResponse EngineId="" HostName="" MaxSeverity="" LogFile="" Class="" Module="" Severity="" Time="">
<Message Code="" Type="" Text="" />
</ErrorResponse>
</Eligibility>
我需要节点
的Eligibility
属性...更新对不起,过早地点击发送。我现在得到的结果只是“未定义”。Property
$(this).contents().find('Property').attr('Eligibility')