1

我觉得我在这里要疯了。

我正在尝试将 XML 数据导入使用 xpathApply 从 usaspending.gov 下载的 R 中。现在,我只是想隔离 DateSigned 属性。我觉得我的 xpath 语法是正确的,但我正在绘制一个空白列表。有什么想法吗?

require(XML)

file1 <- "FY12.xml"

download.file("http://usaspending.gov/fpds/fpds.php?detail=b&fiscal_year=2012&maj_agency_cat=97&max_records=10", file1, method="auto")

doc <- xmlTreeParse(file1, useInternalNode = TRUE)
top <- xmlRoot(doc)
test <- xpathApply(top, "/usaspendingSearchResults/result/doc/DateSigned", xmlValue)

编辑添加 XML 代码:

<?xml version="1.0" encoding="utf-8"?>
<usaspendingSearchResults xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://usaspending.gov/schemas/" xsi:noNamespaceSchemaLocation="http://usaspending.gov/schemas/PrimeBasicContracts.xsd">
  <search_criteria>
    <search_criterion field="fiscal_year" value="2012"/>
    <search_criterion field="maj_contracting_agency" value="97*"/>
    <search_criterion field="Contracts" value="c"/>
    <search_criterion field="sortby" value="DOLLARS_OBLIGATED desc"/>
    <search_criterion field="records_from" value="0"/>
    <search_criterion field="max_records" value="10"/>
  </search_criteria>
  <result numFound="1463044" max_records="10">
    <doc spendingCategory="Contracts">
      <record_count/>
      <AwardType>Definitive Contract</AwardType>
      <ContractPricing>Firm Fixed Price</ContractPricing>
      <ContractingAgency>DEPT OF THE AIR FORCE</ContractingAgency>
      <DUNSNumber>149879157</DUNSNumber>
      <parentDUNSNumber>009256819</parentDUNSNumber>
      <DateSigned>2012-03-08T05:00:00Z</DateSigned>
      <ContractDescription>RSAF F-15 FLEET MODERNIZATION PROGRAM</ContractDescription>
      <ReasonForModification/>
      <DollarsObligated>3373879999.98</DollarsObligated>
      <ExtentCompeted>NOT AVAILABLE FOR COMPETITION</ExtentCompeted>
      <FiscalYear>2012</FiscalYear>
      <TransactionNumber>14</TransactionNumber>
      <FundingAgency>5700</FundingAgency>
      <IDVProcurementInstrumentID/>
      <MajorAgency>9700</MajorAgency>
      <ContractingAgencyCode>5700</ContractingAgencyCode>
      <MajorFundingAgency>9700</MajorFundingAgency>
      <ModificationNumber>0</ModificationNumber>
      <PSCCategoryCode>1510</PSCCategoryCode>
      <ParentRecipientOrCompanyName>THE BOEING COMPANY</ParentRecipientOrCompanyName>
      <PlaceofPerformanceCongDistrict>MO01</PlaceofPerformanceCongDistrict>
      <PlaceofPerformanceState>MISSOURI</PlaceofPerformanceState>
      <PlaceofPerformanceZipCode>631341939</PlaceofPerformanceZipCode>
      <PrincipalNAICSCode>336411</PrincipalNAICSCode>
      <ProcurementInstrumentID>FA863412C2651</ProcurementInstrumentID>
      <PrincipalPlaceCountyOrCity/>
      <ProductorServiceCode>1510</ProductorServiceCode>
      <ProgramSource/>
      <ProgramSourceAccountCode>8242</ProgramSourceAccountCode>
      <ProgramSourceAgencyCode>97</ProgramSourceAgencyCode>
      <ProgramSourceDescription/>
      <RecipientAddressLine123>6200 JS MCDONNELL BLVD, , </RecipientAddressLine123>
      <RecipientCity>SAINT LOUIS</RecipientCity>
      <RecipientCongressionalDistrict>MO01</RecipientCongressionalDistrict>
      <RecipientCountyName>SAINT LOUIS</RecipientCountyName>
      <RecipientName>BOEING COMPANY, THE</RecipientName>
      <RecipientOrContractorName>BOEING COMPANY, THE</RecipientOrContractorName>
      <RecipientState>MO</RecipientState>
      <RecipientZipCode>631341939</RecipientZipCode>
      <TypeofSpending>c</TypeofSpending>
      <TypeofTransaction>Definitive Contract</TypeofTransaction>
    </doc>
    <doc spendingCategory="Contracts">
      <record_count/>
      <AwardType>Definitive Contract</AwardType>
      <ContractPricing>Combination (two or more)</ContractPricing>
      <ContractingAgency>DEPT OF THE NAVY</ContractingAgency>
      <DUNSNumber>963737366</DUNSNumber>
      <parentDUNSNumber>001381284</parentDUNSNumber>
      <DateSigned>2012-01-31T05:00:00Z</DateSigned>
      <ContractDescription>CONSTRUCTION OF SSN 784 (FY 09)</ContractDescription>
      <ReasonForModification>FUNDING ONLY ACTION</ReasonForModification>
      <DollarsObligated>2712135779.00</DollarsObligated>
      <ExtentCompeted>NOT COMPETED</ExtentCompeted>
      <FiscalYear>2012</FiscalYear>
      <TransactionNumber>0</TransactionNumber>
      <FundingAgency>1700</FundingAgency>
      <IDVProcurementInstrumentID/>
      <MajorAgency>9700</MajorAgency>
      <ContractingAgencyCode>1700</ContractingAgencyCode>
      <MajorFundingAgency>9700</MajorFundingAgency>
      <ModificationNumber>P00022</ModificationNumber>
      <PSCCategoryCode>1904</PSCCategoryCode>
      <ParentRecipientOrCompanyName>GENERAL DYNAMICS CORPORATION</ParentRecipientOrCompanyName>
      <PlaceofPerformanceCongDistrict>CT02</PlaceofPerformanceCongDistrict>
      <PlaceofPerformanceState>CONNECTICUT</PlaceofPerformanceState>
      <PlaceofPerformanceZipCode>063404909</PlaceofPerformanceZipCode>
      <PrincipalNAICSCode>336611</PrincipalNAICSCode>
      <ProcurementInstrumentID>N0002409C2104</ProcurementInstrumentID>
      <PrincipalPlaceCountyOrCity/>
      <ProductorServiceCode>1904</ProductorServiceCode>
      <ProgramSource/>
      <ProgramSourceAccountCode>1611</ProgramSourceAccountCode>
      <ProgramSourceAgencyCode>17</ProgramSourceAgencyCode>
      <ProgramSourceDescription/>
      <RecipientAddressLine123>75 EASTERN POINT RD, , </RecipientAddressLine123>
      <RecipientCity>GROTON</RecipientCity>
      <RecipientCongressionalDistrict>CT02</RecipientCongressionalDistrict>
      <RecipientCountyName>NEW LONDON</RecipientCountyName>
      <RecipientName>ELECTRIC BOAT CORPORATION</RecipientName>
      <RecipientOrContractorName>ELECTRIC BOAT CORPORATION</RecipientOrContractorName>
      <RecipientState>CT</RecipientState>
      <RecipientZipCode>063404905</RecipientZipCode>
      <TypeofSpending>c</TypeofSpending>
      <TypeofTransaction>Definitive Contract</TypeofTransaction>
    </doc>
    <doc spendingCategory="Contracts">
      <record_count/>
      <AwardType>Definitive Contract</AwardType>
      <ContractPricing>Cost Plus Fixed Fee</ContractPricing>
      <ContractingAgency>DEPT OF THE NAVY</ContractingAgency>
      <DUNSNumber>830135799</DUNSNumber>
      <parentDUNSNumber>967362331</parentDUNSNumber>
      <DateSigned>2012-05-31T04:00:00Z</DateSigned>
      <ContractDescription>AWARD OF LHA 7 DETAIL DESIGN AND CONSTRUCTION.</ContractDescription>
      <ReasonForModification>ADDITIONAL WORK (NEW AGREEMENT,FAR PART 6 APPLIES)</ReasonForModification>
      <DollarsObligated>2156714483.00</DollarsObligated>
      <ExtentCompeted>NOT COMPETED</ExtentCompeted>
      <FiscalYear>2012</FiscalYear>
      <TransactionNumber>0</TransactionNumber>
      <FundingAgency>1700</FundingAgency>
      <IDVProcurementInstrumentID/>
      <MajorAgency>9700</MajorAgency>
      <ContractingAgencyCode>1700</ContractingAgencyCode>
      <MajorFundingAgency>9700</MajorFundingAgency>
      <ModificationNumber>P00016</ModificationNumber>
      <PSCCategoryCode>1911</PSCCategoryCode>
      <ParentRecipientOrCompanyName>Huntington Ingalls Industries  Inc.</ParentRecipientOrCompanyName>
      <PlaceofPerformanceCongDistrict>MS04</PlaceofPerformanceCongDistrict>
      <PlaceofPerformanceState>MISSISSIPPI</PlaceofPerformanceState>
      <PlaceofPerformanceZipCode>395680149</PlaceofPerformanceZipCode>
      <PrincipalNAICSCode>336611</PrincipalNAICSCode>
      <ProcurementInstrumentID>N0002410C2229</ProcurementInstrumentID>
      <PrincipalPlaceCountyOrCity/>
      <ProductorServiceCode>1911</ProductorServiceCode>
      <ProgramSource/>
      <ProgramSourceAccountCode>1611</ProgramSourceAccountCode>
      <ProgramSourceAgencyCode>17</ProgramSourceAgencyCode>
      <ProgramSourceDescription/>
      <RecipientAddressLine123>1000 ACCESS RD, , </RecipientAddressLine123>
      <RecipientCity>PASCAGOULA</RecipientCity>
      <RecipientCongressionalDistrict>MS00</RecipientCongressionalDistrict>
      <RecipientCountyName>JACKSON</RecipientCountyName>
      <RecipientName>NORTHROP GRUMMAN SHIPBUILDING, INC.</RecipientName>
      <RecipientOrContractorName>NORTHROP GRUMMAN SHIPBUILDING, INC.</RecipientOrContractorName>
      <RecipientState>MS</RecipientState>
      <RecipientZipCode>395670149</RecipientZipCode>
      <TypeofSpending>c</TypeofSpending>
      <TypeofTransaction>Definitive Contract</TypeofTransaction>
    </doc>
    <doc spendingCategory="Contracts">
      <record_count/>
      <AwardType>Definitive Contract</AwardType>
      <ContractPricing>Firm Fixed Price</ContractPricing>
      <ContractingAgency>DEPT OF THE AIR FORCE</ContractingAgency>
      <DUNSNumber>832963495</DUNSNumber>
      <parentDUNSNumber>009256819</parentDUNSNumber>
      <DateSigned>2012-06-22T04:00:00Z</DateSigned>
      <ContractDescription>F-15 S/SA CONVERSION&amp;PROVISIOING</ContractDescription>
      <ReasonForModification/>
      <DollarsObligated>1828165500.00</DollarsObligated>
      <ExtentCompeted>NOT AVAILABLE FOR COMPETITION</ExtentCompeted>
      <FiscalYear>2012</FiscalYear>
      <TransactionNumber>6</TransactionNumber>
      <FundingAgency>5700</FundingAgency>
      <IDVProcurementInstrumentID/>
      <MajorAgency>9700</MajorAgency>
      <ContractingAgencyCode>5700</ContractingAgencyCode>
      <MajorFundingAgency>9700</MajorFundingAgency>
      <ModificationNumber>0</ModificationNumber>
      <PSCCategoryCode>J016</PSCCategoryCode>
      <ParentRecipientOrCompanyName>THE BOEING COMPANY</ParentRecipientOrCompanyName>
      <PlaceofPerformanceCongDistrict>MO01</PlaceofPerformanceCongDistrict>
      <PlaceofPerformanceState>MISSOURI</PlaceofPerformanceState>
      <PlaceofPerformanceZipCode>631341939</PlaceofPerformanceZipCode>
      <PrincipalNAICSCode>336413</PrincipalNAICSCode>
      <ProcurementInstrumentID>FA850512C0001</ProcurementInstrumentID>
      <PrincipalPlaceCountyOrCity/>
      <ProductorServiceCode>J016</ProductorServiceCode>
      <ProgramSource/>
      <ProgramSourceAccountCode>8242</ProgramSourceAccountCode>
      <ProgramSourceAgencyCode>97</ProgramSourceAgencyCode>
      <ProgramSourceDescription/>
      <RecipientAddressLine123>6200 J S MCDONNELL BLVD, , </RecipientAddressLine123>
      <RecipientCity>SAINT LOUIS</RecipientCity>
      <RecipientCongressionalDistrict>MO01</RecipientCongressionalDistrict>
      <RecipientCountyName>SAINT LOUIS</RecipientCountyName>
      <RecipientName>BOEING COMPANY, THE</RecipientName>
      <RecipientOrContractorName>BOEING COMPANY, THE</RecipientOrContractorName>
      <RecipientState>MO</RecipientState>
      <RecipientZipCode>631341939</RecipientZipCode>
      <TypeofSpending>c</TypeofSpending>
      <TypeofTransaction>Definitive Contract</TypeofTransaction>
    </doc>
    <doc spendingCategory="Contracts">
      <record_count/>
      <AwardType>Definitive Contract</AwardType>
      <ContractPricing>Fixed Price Incentive</ContractPricing>
      <ContractingAgency>DEPT OF THE NAVY</ContractingAgency>
      <DUNSNumber>106632750</DUNSNumber>
      <parentDUNSNumber>106632750</parentDUNSNumber>
      <DateSigned>2011-11-23T05:00:00Z</DateSigned>
      <ContractDescription>LOT 16 MV FULL FUNDING</ContractDescription>
      <ReasonForModification>FUNDING ONLY ACTION</ReasonForModification>
      <DollarsObligated>1681280764.36</DollarsObligated>
      <ExtentCompeted>NOT COMPETED</ExtentCompeted>
      <FiscalYear>2012</FiscalYear>
      <TransactionNumber>0</TransactionNumber>
      <FundingAgency>1700</FundingAgency>
      <IDVProcurementInstrumentID/>
      <MajorAgency>9700</MajorAgency>
      <ContractingAgencyCode>1700</ContractingAgencyCode>
      <MajorFundingAgency>9700</MajorFundingAgency>
      <ModificationNumber>P00173</ModificationNumber>
      <PSCCategoryCode>1520</PSCCategoryCode>
      <ParentRecipientOrCompanyName>BELL BOEING JOINT PROJECT OFFICE</ParentRecipientOrCompanyName>
      <PlaceofPerformanceCongDistrict>TX13</PlaceofPerformanceCongDistrict>
      <PlaceofPerformanceState>TEXAS</PlaceofPerformanceState>
      <PlaceofPerformanceZipCode>791111200</PlaceofPerformanceZipCode>
      <PrincipalNAICSCode>336411</PrincipalNAICSCode>
      <ProcurementInstrumentID>N0001907C0001</ProcurementInstrumentID>
      <PrincipalPlaceCountyOrCity/>
      <ProductorServiceCode>1520</ProductorServiceCode>
      <ProgramSource/>
      <ProgramSourceAccountCode>1506</ProgramSourceAccountCode>
      <ProgramSourceAgencyCode>17</ProgramSourceAgencyCode>
      <ProgramSourceDescription/>
      <RecipientAddressLine123>401 TILTROTOR DR, , </RecipientAddressLine123>
      <RecipientCity>AMARILLO</RecipientCity>
      <RecipientCongressionalDistrict>TX13</RecipientCongressionalDistrict>
      <RecipientCountyName>POTTER</RecipientCountyName>
      <RecipientName>BELL BOEING JOINT PROJECT OFFICE</RecipientName>
      <RecipientOrContractorName>BELL BOEING JOINT PROJECT OFFICE</RecipientOrContractorName>
      <RecipientState>TX</RecipientState>
      <RecipientZipCode>791111200</RecipientZipCode>
      <TypeofSpending>c</TypeofSpending>
      <TypeofTransaction>Definitive Contract</TypeofTransaction>
    </doc>
    <doc spendingCategory="Contracts">
      <record_count/>
      <AwardType>Definitive Contract</AwardType>
      <ContractPricing>Firm Fixed Price</ContractPricing>
      <ContractingAgency>DEPT OF THE NAVY</ContractingAgency>
      <DUNSNumber>039267141</DUNSNumber>
      <parentDUNSNumber>009256819</parentDUNSNumber>
      <DateSigned>2012-09-21T04:00:00Z</DateSigned>
      <ContractDescription>DEFINITIZE P-8A LRIP III AIRCRAFT</ContractDescription>
      <ReasonForModification>OTHER ADMINISTRATIVE ACTION</ReasonForModification>
      <DollarsObligated>1600492644.00</DollarsObligated>
      <ExtentCompeted>NOT COMPETED</ExtentCompeted>
      <FiscalYear>2012</FiscalYear>
      <TransactionNumber>0</TransactionNumber>
      <FundingAgency>1700</FundingAgency>
      <IDVProcurementInstrumentID/>
      <MajorAgency>9700</MajorAgency>
      <ContractingAgencyCode>1700</ContractingAgencyCode>
      <MajorFundingAgency>9700</MajorFundingAgency>
      <ModificationNumber>P00045</ModificationNumber>
      <PSCCategoryCode>1560</PSCCategoryCode>
      <ParentRecipientOrCompanyName>THE BOEING COMPANY</ParentRecipientOrCompanyName>
      <PlaceofPerformanceCongDistrict>WA09</PlaceofPerformanceCongDistrict>
      <PlaceofPerformanceState>WASHINGTON</PlaceofPerformanceState>
      <PlaceofPerformanceZipCode>980322316</PlaceofPerformanceZipCode>
      <PrincipalNAICSCode>336411</PrincipalNAICSCode>
      <ProcurementInstrumentID>N0001909C0022</ProcurementInstrumentID>
      <PrincipalPlaceCountyOrCity/>
      <ProductorServiceCode>1560</ProductorServiceCode>
      <ProgramSource/>
      <ProgramSourceAccountCode>1506</ProgramSourceAccountCode>
      <ProgramSourceAgencyCode>17</ProgramSourceAgencyCode>
      <ProgramSourceDescription/>
      <RecipientAddressLine123>20403 68TH AVE S MS 8K-10, , </RecipientAddressLine123>
      <RecipientCity>KENT</RecipientCity>
      <RecipientCongressionalDistrict>WA09</RecipientCongressionalDistrict>
      <RecipientCountyName>KING</RecipientCountyName>
      <RecipientName>THE BOEING COMPANY</RecipientName>
      <RecipientOrContractorName>THE BOEING COMPANY</RecipientOrContractorName>
      <RecipientState>WA</RecipientState>
      <RecipientZipCode>980322316</RecipientZipCode>
      <TypeofSpending>c</TypeofSpending>
      <TypeofTransaction>Definitive Contract</TypeofTransaction>
    </doc>
    <doc spendingCategory="Contracts">
      <record_count/>
      <AwardType>Definitive Contract</AwardType>
      <ContractPricing>Fixed Price Incentive</ContractPricing>
      <ContractingAgency>DEPT OF THE NAVY</ContractingAgency>
      <DUNSNumber>008016958</DUNSNumber>
      <parentDUNSNumber>834951691</parentDUNSNumber>
      <DateSigned>2011-12-09T05:00:00Z</DateSigned>
      <ContractDescription>AUTHORIZE EFFORTS ASSOCIATED WITH LRIP 5 PRODUCTION UNDEFINITIEZED CONTRACT ACTION (UCA)</ContractDescription>
      <ReasonForModification>ADDITIONAL WORK (NEW AGREEMENT,FAR PART 6 APPLIES)</ReasonForModification>
      <DollarsObligated>1592408644.00</DollarsObligated>
      <ExtentCompeted>NOT COMPETED</ExtentCompeted>
      <FiscalYear>2012</FiscalYear>
      <TransactionNumber>0</TransactionNumber>
      <FundingAgency>1700</FundingAgency>
      <IDVProcurementInstrumentID/>
      <MajorAgency>9700</MajorAgency>
      <ContractingAgencyCode>1700</ContractingAgencyCode>
      <MajorFundingAgency>9700</MajorFundingAgency>
      <ModificationNumber>P00014</ModificationNumber>
      <PSCCategoryCode>1510</PSCCategoryCode>
      <ParentRecipientOrCompanyName>LOCKHEED MARTIN CORPORATION</ParentRecipientOrCompanyName>
      <PlaceofPerformanceCongDistrict>TX12</PlaceofPerformanceCongDistrict>
      <PlaceofPerformanceState>TEXAS</PlaceofPerformanceState>
      <PlaceofPerformanceZipCode>761017450</PlaceofPerformanceZipCode>
      <PrincipalNAICSCode>336411</PrincipalNAICSCode>
      <ProcurementInstrumentID>N0001910C0002</ProcurementInstrumentID>
      <PrincipalPlaceCountyOrCity/>
      <ProductorServiceCode>1510</ProductorServiceCode>
      <ProgramSource/>
      <ProgramSourceAccountCode>3010</ProgramSourceAccountCode>
      <ProgramSourceAgencyCode>57</ProgramSourceAgencyCode>
      <ProgramSourceDescription/>
      <RecipientAddressLine123>LOCKHEED BLVD, , </RecipientAddressLine123>
      <RecipientCity>FORT WORTH</RecipientCity>
      <RecipientCongressionalDistrict>TX00</RecipientCongressionalDistrict>
      <RecipientCountyName>TARRANT</RecipientCountyName>
      <RecipientName>LOCKHEED MARTIN CORPORATION</RecipientName>
      <RecipientOrContractorName>LOCKHEED MARTIN CORPORATION</RecipientOrContractorName>
      <RecipientState>TX</RecipientState>
      <RecipientZipCode>761087450</RecipientZipCode>
      <TypeofSpending>c</TypeofSpending>
      <TypeofTransaction>Definitive Contract</TypeofTransaction>
    </doc>
    <doc spendingCategory="Contracts">
      <record_count/>
      <AwardType>Definitive Contract</AwardType>
      <ContractPricing>Firm Fixed Price</ContractPricing>
      <ContractingAgency>DEPT OF THE ARMY</ContractingAgency>
      <DUNSNumber>835551474</DUNSNumber>
      <parentDUNSNumber>001344142</parentDUNSNumber>
      <DateSigned>2012-06-06T04:00:00Z</DateSigned>
      <ContractDescription>MULTI SERVICE, 5 YR, MULTI-YR CONTRACT FOR H-60 HELICOPTERS.  FY2012 ¿ FY2016 PRODUCTION CONTRACT FOR ARMY/NAVY/FMS UH/HH/MH-60 HELICOPTERS TO INCLUDE PROCUREMENT OF UP TO 916 EACH AIRCRAFT AND RELATED SUPPORT, SERVICES, SYSTEMS/PROJECT MANAGEMENT, PUBLICATIONS, AND TECHNICAL DATA.  FMS COUNTRIES INCLUDE SAUDI ARABIAN NATIONAL GUARD (SANG), TAIWAN, THAILAND AND ROYAL AUSTRALIAN NAVY (RAN).</ContractDescription>
      <ReasonForModification/>
      <DollarsObligated>1543229958.00</DollarsObligated>
      <ExtentCompeted>NOT COMPETED</ExtentCompeted>
      <FiscalYear>2012</FiscalYear>
      <TransactionNumber>1</TransactionNumber>
      <FundingAgency>2100</FundingAgency>
      <IDVProcurementInstrumentID/>
      <MajorAgency>9700</MajorAgency>
      <ContractingAgencyCode>2100</ContractingAgencyCode>
      <MajorFundingAgency>9700</MajorFundingAgency>
      <ModificationNumber>0</ModificationNumber>
      <PSCCategoryCode>1520</PSCCategoryCode>
      <ParentRecipientOrCompanyName>UNITED TECHNOLOGIES CORPORATION</ParentRecipientOrCompanyName>
      <PlaceofPerformanceCongDistrict>CT03</PlaceofPerformanceCongDistrict>
      <PlaceofPerformanceState>CONNECTICUT</PlaceofPerformanceState>
      <PlaceofPerformanceZipCode>066141385</PlaceofPerformanceZipCode>
      <PrincipalNAICSCode>336411</PrincipalNAICSCode>
      <ProcurementInstrumentID>W58RGZ12C0008</ProcurementInstrumentID>
      <PrincipalPlaceCountyOrCity/>
      <ProductorServiceCode>1520</ProductorServiceCode>
      <ProgramSource/>
      <ProgramSourceAccountCode>2031</ProgramSourceAccountCode>
      <ProgramSourceAgencyCode>21</ProgramSourceAgencyCode>
      <ProgramSourceDescription/>
      <RecipientAddressLine123>6900 MAIN ST, , </RecipientAddressLine123>
      <RecipientCity>STRATFORD</RecipientCity>
      <RecipientCongressionalDistrict>CT03</RecipientCongressionalDistrict>
      <RecipientCountyName>FAIRFIELD</RecipientCountyName>
      <RecipientName>SIKORSKY AIRCRAFT CORPORATION</RecipientName>
      <RecipientOrContractorName>SIKORSKY AIRCRAFT CORPORATION</RecipientOrContractorName>
      <RecipientState>CT</RecipientState>
      <RecipientZipCode>066141385</RecipientZipCode>
      <TypeofSpending>c</TypeofSpending>
      <TypeofTransaction>Definitive Contract</TypeofTransaction>
    </doc>
    <doc spendingCategory="Contracts">
      <record_count/>
      <AwardType>Delivery Order</AwardType>
      <ContractPricing>Fixed Price with Economic Price Adjustment</ContractPricing>
      <ContractingAgency>DEFENSE LOGISTICS AGENCY</ContractingAgency>
      <DUNSNumber>004294737</DUNSNumber>
      <parentDUNSNumber>423792808</parentDUNSNumber>
      <DateSigned>2012-09-20T04:00:00Z</DateSigned>
      <ContractDescription>AWARD JP5 
CLIN 0101 FOR 82,349,000 FOB ORIGIN DEER PARK, TX BY TANKER
CLIN 0201 FOR 212,860,000 FOB ORIGIN DEER PARK, TX BY PIPELINE

AWARD JP8
CLIN 0301 FOR 118,701,000 FOB ORIGIN DEER PARK, TX BY PIPELINE</ContractDescription>
      <ReasonForModification/>
      <DollarsObligated>1358320745.62</DollarsObligated>
      <ExtentCompeted>FULL AND OPEN COMPETITION</ExtentCompeted>
      <FiscalYear>2012</FiscalYear>
      <TransactionNumber>0</TransactionNumber>
      <FundingAgency>97AS</FundingAgency>
      <IDVProcurementInstrumentID>SP060012D0510</IDVProcurementInstrumentID>
      <MajorAgency>9700</MajorAgency>
      <ContractingAgencyCode>97AS</ContractingAgencyCode>
      <MajorFundingAgency>9700</MajorFundingAgency>
      <ModificationNumber>0</ModificationNumber>
      <PSCCategoryCode>9130</PSCCategoryCode>
      <ParentRecipientOrCompanyName>ROYAL DUTCH SHELL PLC</ParentRecipientOrCompanyName>
      <PlaceofPerformanceCongDistrict>TX18</PlaceofPerformanceCongDistrict>
      <PlaceofPerformanceState>TEXAS</PlaceofPerformanceState>
      <PlaceofPerformanceZipCode>770024916</PlaceofPerformanceZipCode>
      <PrincipalNAICSCode>324110</PrincipalNAICSCode>
      <ProcurementInstrumentID>B001</ProcurementInstrumentID>
      <PrincipalPlaceCountyOrCity/>
      <ProductorServiceCode>9130</ProductorServiceCode>
      <ProgramSource/>
      <ProgramSourceAccountCode>4930</ProgramSourceAccountCode>
      <ProgramSourceAgencyCode>97</ProgramSourceAgencyCode>
      <ProgramSourceDescription/>
      <RecipientAddressLine123>910 LOUISIANA ST STE 2, , </RecipientAddressLine123>
      <RecipientCity>HOUSTON</RecipientCity>
      <RecipientCongressionalDistrict>TX18</RecipientCongressionalDistrict>
      <RecipientCountyName>HARRIS</RecipientCountyName>
      <RecipientName>EQUILON ENTERPRISES LLC</RecipientName>
      <RecipientOrContractorName>EQUILON ENTERPRISES LLC</RecipientOrContractorName>
      <RecipientState>TX</RecipientState>
      <RecipientZipCode>770024916</RecipientZipCode>
      <TypeofSpending>c</TypeofSpending>
      <TypeofTransaction>Delivery Order</TypeofTransaction>
    </doc>
    <doc spendingCategory="Contracts">
      <record_count/>
      <AwardType>Definitive Contract</AwardType>
      <ContractPricing>Firm Fixed Price</ContractPricing>
      <ContractingAgency>DEPT OF THE ARMY</ContractingAgency>
      <DUNSNumber>835551474</DUNSNumber>
      <parentDUNSNumber>001344142</parentDUNSNumber>
      <DateSigned>2012-06-06T04:00:00Z</DateSigned>
      <ContractDescription>MULTI SERVICE, 5 YR, MULTI-YR CONTRACT FOR H-60 HELICOPTERS.  FY2012 ¿ FY2016 PRODUCTION CONTRACT FOR ARMY/NAVY/FMS UH/HH/MH-60 HELICOPTERS TO INCLUDE PROCUREMENT OF UP TO 916 EACH AIRCRAFT AND RELATED SUPPORT, SERVICES, SYSTEMS/PROJECT MANAGEMENT, PUBLICATIONS, AND TECHNICAL DATA.  FMS COUNTRIES INCLUDE SAUDI ARABIAN NATIONAL GUARD (SANG), TAIWAN, THAILAND AND ROYAL AUSTRALIAN NAVY (RAN).</ContractDescription>
      <ReasonForModification/>
      <DollarsObligated>1284346737.00</DollarsObligated>
      <ExtentCompeted>NOT COMPETED</ExtentCompeted>
      <FiscalYear>2012</FiscalYear>
      <TransactionNumber>2</TransactionNumber>
      <FundingAgency>2100</FundingAgency>
      <IDVProcurementInstrumentID/>
      <MajorAgency>9700</MajorAgency>
      <ContractingAgencyCode>2100</ContractingAgencyCode>
      <MajorFundingAgency>9700</MajorFundingAgency>
      <ModificationNumber>0</ModificationNumber>
      <PSCCategoryCode>1520</PSCCategoryCode>
      <ParentRecipientOrCompanyName>UNITED TECHNOLOGIES CORPORATION</ParentRecipientOrCompanyName>
      <PlaceofPerformanceCongDistrict>CT03</PlaceofPerformanceCongDistrict>
      <PlaceofPerformanceState>CONNECTICUT</PlaceofPerformanceState>
      <PlaceofPerformanceZipCode>066141385</PlaceofPerformanceZipCode>
      <PrincipalNAICSCode>336411</PrincipalNAICSCode>
      <ProcurementInstrumentID>W58RGZ12C0008</ProcurementInstrumentID>
      <PrincipalPlaceCountyOrCity/>
      <ProductorServiceCode>1520</ProductorServiceCode>
      <ProgramSource/>
      <ProgramSourceAccountCode>8242</ProgramSourceAccountCode>
      <ProgramSourceAgencyCode>11</ProgramSourceAgencyCode>
      <ProgramSourceDescription/>
      <RecipientAddressLine123>6900 MAIN ST, , </RecipientAddressLine123>
      <RecipientCity>STRATFORD</RecipientCity>
      <RecipientCongressionalDistrict>CT03</RecipientCongressionalDistrict>
      <RecipientCountyName>FAIRFIELD</RecipientCountyName>
      <RecipientName>SIKORSKY AIRCRAFT CORPORATION</RecipientName>
      <RecipientOrContractorName>SIKORSKY AIRCRAFT CORPORATION</RecipientOrContractorName>
      <RecipientState>CT</RecipientState>
      <RecipientZipCode>066141385</RecipientZipCode>
      <TypeofSpending>c</TypeofSpending>
      <TypeofTransaction>Definitive Contract</TypeofTransaction>
    </doc>
  </result>
</usaspendingSearchResults>
4

3 回答 3

3
require(XML)
require(RCurl)
rURL <- "http://usaspending.gov/fpds/fpds.php?detail=b&fiscal_year=2012&maj_agency_cat=97&max_records=10"
rData <- getURL(rURL, useragent = 'mozilla', followlocation = TRUE)
xData <- xmlParse(rData)

观察

> xmlNamespaceDefinitions(xData ,simplify = TRUE)
                                        xsi 
"http://www.w3.org/2001/XMLSchema-instance" 

          "http://usaspending.gov/schemas/" 
attr(,"class")
[1] "SimplifiedXMLNamespaceDefinitions" "XMLNamespaceDefinitions"  

所以有多个命名空间定义。告诉 R 使用哪个

test <- xpathApply(xData, "//def:DateSigned"
                        , namespaces = c(def = "http://usaspending.gov/schemas/"))


> test
[[1]]
<DateSigned>2012-03-08T05:00:00Z</DateSigned> 

[[2]]
<DateSigned>2012-01-31T05:00:00Z</DateSigned> 

[[3]]
<DateSigned>2012-05-31T04:00:00Z</DateSigned> 

[[4]]
<DateSigned>2012-06-22T04:00:00Z</DateSigned> 

请参阅如何使用 R 的 XML 库使用 xpath 查询?了解更多详情。

来自 `?xpathApply'

在 XML 文档中的节点上定义命名空间时,XPath 表达式必须使用命名空间,即使它是 XML 文档/节点的默认命名空间。例如,假设我们有一个 XML 文档 '...' 要查找所有主题节点,我们可能想要使用 XPath 表达式 '"/help/topic"'。但是,我们必须使用与 URI '<a href="http://www.r-project.org/Rd" rel="nofollow noreferrer">http://www.r- 关联的显式命名空间前缀project.org/Rd' 对应于 XML 文档中的那个。所以我们会使用 'getNodeSet(doc, "/r:help/r:topic", c(r = " http://www.r-project.org/Rd "))'。

于 2013-06-18T04:34:34.517 回答
1

另一种方法是:

test = getNodeSet(doc, "//*[local-name() = 'DateSigned']")
于 2013-06-18T12:01:52.400 回答
0

您可以使用很多在线工具来测试您的 XPath 与 XML,例如:

第一个甚至对最常见的情况有一些最少的 1 行描述。可能这些可以帮助你。这可能是一个微不足道的命名空间映射问题,否则您的 XPath 对我来说看起来不错。

于 2013-06-18T01:01:27.287 回答