E. Vincenti
E. Vincenti

Reputation: 407

Importing XML data into R

I feel like I'm going insane here.

I'm trying to import XML data into R that I've downloaded from usaspending.gov using xpathApply. Right now, I'm just trying to isolate the DateSigned attiribute. I feel like my xpath syntax is correct, but I'm drawing a blank list. Any thoughts?

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)

EDITED TO ADD THE XML CODE:

<?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>

Upvotes: 1

Views: 4547

Answers (3)

topchef
topchef

Reputation: 19783

Another way is:

test = getNodeSet(doc, "//*[local-name() = 'DateSigned']")

Upvotes: 1

user1609452
user1609452

Reputation: 4444

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)

Observe

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

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

so there are multiple namespace defintions. Tell R which to use

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> 

See How can I use xpath querying using R's XML library? for further details.

From `?xpathApply'

When a namespace is defined on a node in the XML document, an XPath expressions must use a namespace, even if it is the default namespace for the XML document/node. For example, suppose we have an XML document ‘...’ To find all the topic nodes, we might want to use the XPath expression ‘"/help/topic"’. However, we must use an explicit namespace prefix that is associated with the URI ‘http://www.r-project.org/Rd’ corresponding to the one in the XML document. So we would use ‘getNodeSet(doc, "/r:help/r:topic", c(r = "http://www.r-project.org/Rd"))’.

Upvotes: 3

rlegendi
rlegendi

Reputation: 10606

There are quite a lot of online tools you can play with to test your XPath against XML, like:

The first one even has some minimal 1-line descriptions on the most common cases. Probably these can help you. It can be a trivial namespace mapping issue, otherwise your XPath looks ok for me.

Upvotes: 0

Related Questions