다음 XML을 구문 분석하여 Nokogiri XML 구문 분석기를 사용하여 행운을 내지 않고 //ns2:Point/ns2:pos
에서 Lat Long 조합을 추출하려고합니다. 그러나 잘 사용Nokogiri를 사용하여 XML 요소의 값을 추출 할 수 없습니다
doc = Nokogiri::XML(response.body);
pos = doc.xpath('//ns2:Point/ns2:pos');
나는 지오 코딩 된 주소 요소에 액세스 할 수 있습니다 : 나는 다음과 같은 시도 할 때
<?xml version="1.0" encoding="UTF-8"?>
<ns1:XLS ns1:lang="en" rel="5.2.sp03" version="1.0" xmlns:ns1="http://www.opengis.net/xls">
<ns1:ResponseHeader sessionID="wrx-rails1370997540"/>
<ns1:Response numberOfResponses="1" requestID="10" version="1.0">
<ns1:GeocodeResponse>
<ns1:GeocodeResponseList numberOfGeocodedAddresses="1">
<ns1:GeocodedAddress>
<ns2:Point xmlns:ns2="http://www.opengis.net/gml">
<ns2:pos>38.898331 -77.117273</ns2:pos>
</ns2:Point>
<ns1:Address countryCode="US">
<ns1:StreetAddress>
<ns1:Building number="4400"/>
<ns1:Street>Lee Hwy</ns1:Street>
</ns1:StreetAddress>
<ns1:Place type="CountrySubdivision">VA</ns1:Place>
<ns1:Place type="CountrySecondarySubdivision">Arlington</ns1:Place>
<ns1:Place type="MunicipalitySubdivision">Arlington</ns1:Place>
<ns1:PostalCode>22207</ns1:PostalCode>
</ns1:Address>
<ns1:GeocodeMatchCode accuracy="1.0" matchType="ADDRESS POINT LOOKUP"/>
<ns1:SpatialKeys>
<ns1:SpatialKey priority="0" val="1663355010"/>
<ns1:SpatialKey priority="1" val="2563322400"/>
<ns1:SpatialKey priority="2" val="3325185160"/>
<ns1:SpatialKey priority="3" val="3784086306"/>
<ns1:SpatialKey priority="4" val="4033029320"/>
<ns1:SpatialKey priority="5" val="4162373938"/>
<ns1:SpatialKey priority="6" val="4228264524"/>
<ns1:SpatialKey priority="7" val="4261514387"/>
<ns1:SpatialKey priority="8" val="4278215460"/>
<ns1:SpatialKey priority="9" val="4286585033"/>
<ns1:SpatialKey priority="10" val="4290774578"/>
<ns1:SpatialKey priority="11" val="4292870540"/>
<ns1:SpatialKey priority="12" val="4293918819"/>
<ns1:SpatialKey priority="13" val="4294443032"/>
<ns1:SpatialKey priority="14" val="4294705158"/>
<ns1:SpatialKey priority="15" val="4294836224"/>
</ns1:SpatialKeys>
</ns1:GeocodedAddress>
</ns1:GeocodeResponseList>
</ns1:GeocodeResponse>
</ns1:Response>
</ns1:XLS>
는 내가 다시 빈 상태 (empty)의 배열이에 관해서는
doc.xpath('//ns1:GeocodeResponseList/ns1:GeocodedAddress')
모든 단서를 내가 여기에 실종 됐어. 어떤 이유로 싫어하는 네임 스페이스가 바뀌 었습니까? 다음과 같이
내 환경은 다음과 같습니다 노코 기리 1.5.9 자바 레일 3.2.11 JRuby를 1.7.4 윈도우 7 상자를