Linq to XML

       解析XML节点的时候,如何一步定位到某个节点呢,可以采用以下办法

  以下就会遍历xml下所有的test节点,无论该节点是在哪一个层级。

XDocument xdoc = XDocument.Load("test.xml");
var testItem= (from test in xdoc.Descendants("test") select test);

 

    如果同一个xml中同一层级存在相同得节点名称,可以通过命名空间区分

<?xml version="1.0" encoding="UTF-8"?>
<edgarSubmission xmlns="http://www.sec.gov/edgar/nmfp" xmlns:com="http://www.sec.gov/edgar/common" xmlns:invest="http://www.sec.gov/edgar/invest" xmlns:part1="http://www.sec.gov/edgar/nmfpfund" xmlns:part2="http://www.sec.gov/edgar/nmfpsecurities" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sec.gov/edgar/nmfp eis_NMFP_Submission.xsd">
  <submissionType>N-MFP/A</submissionType>
  <liveTestFlag>LIVE</liveTestFlag>
  <isThisElectronicCopyOfPaperFormat>N</isThisElectronicCopyOfPaperFormat>
  <DocumentPeriodEndDate>2014-10-31</DocumentPeriodEndDate>
  <EntityCentralIndexKey>0000822977</EntityCentralIndexKey>
  <seriesId>S000009259</seriesId>
  <totalClassesInSeries>9</totalClassesInSeries>
  <isThisFinalFiling>N</isThisFinalFiling>
  <isFundLiquidating>N</isFundLiquidating>
  <isFundMergingWithOrBeingAcquiredByAnotherFund>N</isFundMergingWithOrBeingAcquiredByAnotherFund>
  <hasFundAcquiredOrMergedWithAnotherFundSinceLastFiling>N</hasFundAcquiredOrMergedWithAnotherFundSinceLastFiling>
  <seriesLevelInformation>
    <part1:ContainedFileInformationFileNumber>033-17619</part1:ContainedFileInformationFileNumber>
    <part1:investmentAdviserList>
      <part1:adviser>
        <part1:adviserName>Goldman Sachs Asset Management, L.P.</part1:adviserName>
        <part1:adviserFileNumber>801-37591</part1:adviserFileNumber>
      </part1:adviser>
    </part1:investmentAdviserList>
    <part1:independentPublicAccountant>
      <part1:name>PricewaterhouseCoopers LLP</part1:name>
      <part1:city>Boston</part1:city>
      <part1:state>MA</part1:state>
    </part1:independentPublicAccountant>
    <part1:administratorList>
      <part1:administrator>Goldman Sachs Asset Management, L.P.</part1:administrator>
      <part1:administrator>The Bank of New York Mellon</part1:administrator>
    </part1:administratorList>
    <part1:transferAgentList>
      <part1:transferAgent>
        <part1:name>Goldman, Sachs &amp; Co.</part1:name>
        <part1:EntityCentralIndexKey>0000734700</part1:EntityCentralIndexKey>
        <part1:fileNumber>84-01100</part1:fileNumber>
      </part1:transferAgent>
    </part1:transferAgentList>
    <part1:isThisFeederFund>N</part1:isThisFeederFund>
    <part1:isThisMasterFund>N</part1:isThisMasterFund>
    <part1:isThisSeriesPrimarilyUsedToFundInsuranceCompanySeperateAccounts>N</part1:isThisSeriesPrimarilyUsedToFundInsuranceCompanySeperateAccounts>
    <part1:InvestmentTypeDomain>Prime</part1:InvestmentTypeDomain>
    <part1:dollarWeightedAveragePortfolioMaturity>46</part1:dollarWeightedAveragePortfolioMaturity>
    <part1:dollarWeightedAverageLifeMaturity>84</part1:dollarWeightedAverageLifeMaturity>
    <part1:AvailableForSaleSecuritiesAmortizedCost>30376398964.38</part1:AvailableForSaleSecuritiesAmortizedCost>
    <part1:OtherAssets>347512625.62</part1:OtherAssets>
    <part1:Liabilities>106243634.11</part1:Liabilities>
    <part1:AssetsNet>30617667955.89</part1:AssetsNet>
    <part1:MoneyMarketSevenDayYield>0.0024</part1:MoneyMarketSevenDayYield>
    <part1:seriesShadowPrice>
      <part1:netValuePerShareIncludingCapitalSupportAgreement>1.0000</part1:netValuePerShareIncludingCapitalSupportAgreement>
      <part1:dateCalculatedFornetValuePerShareIncludingCapitalSupportAgreement>2014-10-31</part1:dateCalculatedFornetValuePerShareIncludingCapitalSupportAgreement>
      <part1:netValuePerShareExcludingCapitalSupportAgreement>1.0000</part1:netValuePerShareExcludingCapitalSupportAgreement>
      <part1:dateCalculatedFornetValuePerShareExcludingCapitalSupportAgreement>2014-10-31</part1:dateCalculatedFornetValuePerShareExcludingCapitalSupportAgreement>
    </part1:seriesShadowPrice>
  </seriesLevelInformation>
  <classLevelInformationList>
    <part1:classLevelInformation>
      <part1:classId>C000025295</part1:classId>
      <part1:minInitialInvestment>10000000.00</part1:minInitialInvestment>
      <part1:netAssetsOfClass>29550496807.58</part1:netAssetsOfClass>
      <part1:netAssetValuePerShare>1.00</part1:netAssetValuePerShare>
      <part1:netShareholderFlowActivityForMonthEnded>-1068554490.39</part1:netShareholderFlowActivityForMonthEnded>
      <part1:grossSubscriptionsForMonthEnded>33990760553.60</part1:grossSubscriptionsForMonthEnded>
      <part1:grossRedemptionsForMonthEnded>35059315043.99</part1:grossRedemptionsForMonthEnded>
      <part1:sevenDayNetYield>0.0006</part1:sevenDayNetYield>
      <part1:classShadowPrice>
        <part1:netAssetValuePerShareIncludingCapitalSupportAgreement>
          <part1:value>1.0000</part1:value>
          <part1:dateAsOfWhichValueWasCalculated>2014-10-31</part1:dateAsOfWhichValueWasCalculated>
        </part1:netAssetValuePerShareIncludingCapitalSupportAgreement>
        <part1:netAssetValuePerShareExcludingCapitalSupportAgreement>
          <part1:value>1.0000</part1:value>
          <part1:dateAsOfWhichValueWasCalculated>2014-10-31</part1:dateAsOfWhichValueWasCalculated>
        </part1:netAssetValuePerShareExcludingCapitalSupportAgreement>
      </part1:classShadowPrice>
    </part1:classLevelInformation>
    <part1:classLevelInformation>
      <part1:classId>C000025296</part1:classId>
      <part1:minInitialInvestment>10000000.00</part1:minInitialInvestment>
      <part1:netAssetsOfClass>325557309.89</part1:netAssetsOfClass>
      <part1:netAssetValuePerShare>1.00</part1:netAssetValuePerShare>
      <part1:netShareholderFlowActivityForMonthEnded>44924724.55</part1:netShareholderFlowActivityForMonthEnded>
      <part1:grossSubscriptionsForMonthEnded>128788631.42</part1:grossSubscriptionsForMonthEnded>
      <part1:grossRedemptionsForMonthEnded>83863906.87</part1:grossRedemptionsForMonthEnded>
      <part1:sevenDayNetYield>0.0001</part1:sevenDayNetYield>
      <part1:classShadowPrice>
        <part1:netAssetValuePerShareIncludingCapitalSupportAgreement>
          <part1:value>1.0000</part1:value>
          <part1:dateAsOfWhichValueWasCalculated>2014-10-31</part1:dateAsOfWhichValueWasCalculated>
        </part1:netAssetValuePerShareIncludingCapitalSupportAgreement>
        <part1:netAssetValuePerShareExcludingCapitalSupportAgreement>
          <part1:value>1.0000</part1:value>
          <part1:dateAsOfWhichValueWasCalculated>2014-10-31</part1:dateAsOfWhichValueWasCalculated>
        </part1:netAssetValuePerShareExcludingCapitalSupportAgreement>
      </part1:classShadowPrice>
    </part1:classLevelInformation>
    <part1:classLevelInformation>
      <part1:classId>C000025297</part1:classId>
      <part1:minInitialInvestment>10000000.00</part1:minInitialInvestment>
      <part1:netAssetsOfClass>20693763.10</part1:netAssetsOfClass>
      <part1:netAssetValuePerShare>1.00</part1:netAssetValuePerShare>
      <part1:netShareholderFlowActivityForMonthEnded>-2394577.57</part1:netShareholderFlowActivityForMonthEnded>
      <part1:grossSubscriptionsForMonthEnded>7866466.05</part1:grossSubscriptionsForMonthEnded>
      <part1:grossRedemptionsForMonthEnded>10261043.62</part1:grossRedemptionsForMonthEnded>
      <part1:sevenDayNetYield>0.0001</part1:sevenDayNetYield>
      <part1:classShadowPrice>
        <part1:netAssetValuePerShareIncludingCapitalSupportAgreement>
          <part1:value>1.0000</part1:value>
          <part1:dateAsOfWhichValueWasCalculated>2014-10-31</part1:dateAsOfWhichValueWasCalculated>
        </part1:netAssetValuePerShareIncludingCapitalSupportAgreement>
        <part1:netAssetValuePerShareExcludingCapitalSupportAgreement>
          <part1:value>1.0000</part1:value>
          <part1:dateAsOfWhichValueWasCalculated>2014-10-31</part1:dateAsOfWhichValueWasCalculated>
        </part1:netAssetValuePerShareExcludingCapitalSupportAgreement>
      </part1:classShadowPrice>
    </part1:classLevelInformation>
View Code

 其中的edgarSubmission属性定义了几个命名空间,别分别起别名Part,Part2等,分别在有的子节点中加上了该命名空间,如 <part1:classLevelInformation>,这样可以对具有另一个相同的<classLevelInformation>节点以示区分.

     如果想遍历特定命名空间的节点可以使用以下方法:

 XNamespace a= "http://test/a/b";
 XNamespace b= "http://test/a/c";
 XDocument xdoc = XDocument.Load(@"D:\test.xml");
 var item=from c in xdoc.Descendants(nmfpNameSpace + "c") select c;

 

posted @ 2016-04-11 22:37  tuohaibei  阅读(403)  评论(0编辑  收藏  举报