많은 유사한 게시물이 있음을 알고 있지만 제안 사항을 성공적으로 구현할 수 없습니다.PHP에서 XML 네임 스페이스 및 스키마 구문 분석
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<message:MessageGroup xmlns:message="http://www.SDMX.org/resources/SDMXML/schemas/v1_0/message" xmlns:common="http://www.SDMX.org/resources/SDMXML/schemas/v1_0/common" xmlns:frb="http://www.federalreserve.gov/structure/compact/common" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.SDMX.org/resources/SDMXML/schemas/v1_0/message SDMXMessage.xsd http://www.federalreserve.gov/structure/compact/common frb_common.xsd">
<?frb EmbargoDate="2017-10-24T00:00:00"?>
<frb:DataSet id="Yields" xmlns:kf="http://www.federalreserve.gov/structure/compact/Yields_Yields" xsi:schemaLocation="http://www.federalreserve.gov/structure/compact/Yields_Yields Yields_Yields.xsd">
</frb:DataSet>
<frb:DataSet id="Yields" xmlns:kf="http://www.federalreserve.gov/structure/compact/Yields_Parameters" xsi:schemaLocation="http://www.federalreserve.gov/structure/compact/Yields_Parameters Yields_Parameters.xsd">
<kf:Series BT="Nominal" CURRENCY="NA" FREQ="9" Parameter="B0" SERIES_NAME="BETA0" UNIT="Number" UNIT_MULT="1">
<frb:Annotations>
<common:Annotation>
<common:AnnotationType>Short Description</common:AnnotationType>
<common:AnnotationText>Beta0 Coefficient for Nominal Treasury Yields as Estimated by the Svensson Term Structure Model</common:AnnotationText>
</common:Annotation>
</frb:Annotations>
<frb:Obs OBS_STATUS="A" OBS_VALUE="3.91760612" TIME_PERIOD="1961-06-14"/>
<frb:Obs OBS_STATUS="A" OBS_VALUE="3.97849787" TIME_PERIOD="1961-06-15"/>
<frb:Obs OBS_STATUS="A" OBS_VALUE="3.98435045" TIME_PERIOD="1961-06-16"/>
<frb:Obs OBS_STATUS="A" OBS_VALUE="4.00437935" TIME_PERIOD="1961-06-19"/>
<frb:Obs OBS_STATUS="A" OBS_VALUE="3.98578922" TIME_PERIOD="1961-06-20"/>
<frb:Obs OBS_STATUS="A" OBS_VALUE="4.00405894" TIME_PERIOD="1961-06-21"/>
<frb:Obs OBS_STATUS="A" OBS_VALUE="4.00089634" TIME_PERIOD="1961-06-22"/>
</kf:Series>
</frb:DataSet>
</message:MessageGroup>
YieldsParameters.xsd 파일 추출물 :
xmlns:frb="http://www.federalreserve.gov/structure/compact/common">
<xs:import namespace="http://www.federalreserve.gov/structure/compact/common" schemaLocation="frb_common.xsd"/>
나는 OBS_VALUE 및 TIME_PERIOD 속성을 검색에 관심이 두 가지 데이터 세트 here와 XML -
나는 다음과 같은 데이터의 추출이 두 번째 데이터 집합에서. 나는 또한 일련의 관찰을 세고 싶다. 내가 관찰 값을 검색하지 않습니다 고려
$myFileXml = 'feds200628.xml';
$xml = simplexml_load_file($myFileXml);
$xml->DataSet[1]->Series[0] as $Ser
$ns_dc = $Ser ->children('http://www.federalreserve.gov/structure/compact/common');
echo $ns_dc->Obs[0]->->Attributes()->OBS_VALUE;
echo $count = count($xml->children('http://www.federalreserve.gov/structure/compact/common',true)->DataSet[1]->Series[0]->Obs);
카운트 내가 여기 아주 기본적인 뭔가를 놓친 거지 믿고, 0 반환 값 : following suggestion 내 샘플 코드를 사용
은 다음과 같습니다. 나는 또한 이상한 그
print_r($xml);
반환 찾기 :
SimpleXMLElement 개체 ([FRB] => SimpleXMLElement 개체() [코멘트] => SimpleXMLElement 오브젝트())
완벽 함, 고맙습니다. – bgolfb
OK - 문제를 해결하면이 대답을 수락 할 수 있습니까? 감사 –