문제

다시 비슷한 질문을해서 죄송합니다. 다음 XML 문서를 읽으려고합니다.

<markets currency="GBP">
  <market id="2908368" nextId="2908395">
    <status>ACTIVE</status>
    <commissionRate>2.5</commissionRate>
    <marketType>ANY_NUMBER_OF_WINNERS</marketType>
    <selections type="MainBets">
      <selection id="658442">
        <name>Player 1</name>
        <resource href="https://api.betfair.com/rest/v1/selection/tradeActivity
           ?username=sampleuser&marketId=2908368&selectionId=658442"
           responseType="selectionTradeActivity" title="Trade Activity"/>
        <status>IN_PLAY</status>   <!-- THIS IS THE VALUE I WANT -->
        <amountMatched>0.0</amountMatched> 
        <bestAvailableToBackPrices/>
        <bestAvailableToLayPrices/>
      </selection>
    </selections>
  </market>
</markets>

내가 원하는 가치를 가진 각각 4 명의 플레이어가 있지만, 각 플레이어의 개인 상태가 아니라 동일한 상태 만 얻을 수 있습니다. 누군가 나를 도와 줄 수 있습니까? 많은 감사합니다

도움이 되었습니까?

해결책

여기에서 xpath를 사용할 수 있습니다

 XmlDocument xmlDoc;
     XmlNode     xmlNode;
     String      xpathExpr;

     xmlDoc = new XmlDocument();
     xmlDoc.LoadXml( "<?xml version='1.0'?><root><person><name>Martin Fowler</name></person><person><name>Kent Beck</name></person><person><name>Dave Astels</name></person></root>" );

     xpathExpr = "/root/person[name='Martin Fowler']";
     xmlNode = xmlDoc.SelectSingleNode(xpathExpr);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top