2009-07-28 7 views
1

특정 노드 :C#을 윈폼 읽기 XML 파일 - 내가 XML 파일이

<Database> 
    <SMS> 
    <Number>+447761692278</Number> 
    <DateTime>2009-07-27T15:20:32</DateTime> 
    <Message>Yes</Message> 
    <FollowedUpBy>Unassigned</FollowedUpBy> 
    <Outcome></Outcome> 
    <Quantity>0</Quantity> 
    <Points>0</Points> 
    </SMS> 
    <SMS> 
    <Number>+447706583066</Number> 
    <DateTime>2009-07-27T15:19:16</DateTime> 
    <Message>STOP</Message> 
    <FollowedUpBy>Unassigned</FollowedUpBy> 
    <Outcome></Outcome> 
    <Quantity>0</Quantity> 
    <Points>0</Points> 
    </SMS> 
    </Database> 

은 현재 내가 이것을 사용하여 DataGridView에로를 읽기 :

난 단지 읽을 수 있도록하려면
public void Read() 
     { 
      DataSet ds = new DataSet("SMS DataSet"); 
      XmlDataDocument xmlDatadoc = new XmlDataDocument(); 
      xmlDatadoc.DataSet.ReadXml(@"C:\Documents and Settings\Administrator\Desktop\RecSmsDB.xml"); 
      ds = xmlDatadoc.DataSet; 
      this.dataGridView1.DataSource = ds; 
      this.dataGridView1.DataMember = "SMS"; 
      this.dataGridView1.Sort(dataGridView1.Columns["DateTime"], ListSortDirection.Descending); 
     } 

특정 DateTime이있는 xml 개체 누구든지이 일을하는 방법을 알고 있습니까? 현재 네임 스페이스에 포함 된 다양한 방법을 시도했지만 아무 소용이 없습니다.

크게 도움을 주시면 감사하겠습니다.

*** 편집 : 런타임에 표시되는 데이터를 동적으로 변경할 수 있어야합니다.

답변

4

나는 생각할 수 없다. 그러나 모든 데이터를 DataSet으로 읽은 다음 SMS 테이블을 필터링하는 DataView를 만들고 DataTable 대신 그리드를 바인딩 할 수 있습니다.

+0

+1 동의. 데이터가 엄청나게 큰 것이 아니라면 DataSet에서 필터링하면됩니다. –

1

DataSet을 BindingSource에 연결하고이 BindingSource를 표에 연결하면 어떻습니까? BindingSource에는 SQL과 같은 표현식을 입력 할 수있는 Filter 속성이 있습니다.