我正在尝试从 URL 中提取 XML 数据。它不是 XML 文件,而是基于请求字符串的响应。
$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>";
$xml = simplexml_load_string($url); // requires allow_url_fopen to be on
$elg = (string)$xml->Property[Eligibility];
var_dump($xml);
我想要的数据如下所示:
<Eligibility>
<Adjusted AnnualIncome="" TotalDeduction="" AdjustedIncome="" ElderlyDeduction="" YoungDeduction="">
</Adjusted>
<Section502Guaranted MaximumAdjusted="" Eligible="">
</Section502Guaranted>
<Section502Direct MaximumAdjusted="" Eligible="">
</Section502Direct>
<Property Eligibility="UnableToVerifyAddress" MapURL="http://rdgdwe.sc.egov.usda.gov/eligibilitymaps/index.jsp?app=RBSIELG&ADDRESS=392 Spruce east alton&STATE=IL&ZIP=62024"/>
<ErrorResponse EngineId="" HostName="" MaxSeverity="" LogFile="" Class="" Module="" Severity="" Time="">
<Message Code="" Type="" Text=""/>
</ErrorResponse>
</Eligibility>
我回来的样子是这样的:
bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false)
我不知道它为什么这样做。也没有错误发布。