locked
XSD xml to dataset RRS feed

  • Question

  • Hello,
    My goal is to create a dataset from an xml file.
    I use this
    C:\TEMP\log>xsd CurrentOrder.xml /outputdir:c:\ProductPrice
    --> is ok.
    My questions are, how do I create new lines (new rows, recordsets), how do I query values (attribute)?
    Delete, edit, add and change/modify it.
    Picture:Test

    Do you have some tips, examples?
      

    I was able to set the table names by name in a dataset.
    I use a dataset without xsd.exe tool.
    DS.DTPositions.AsEnumerable()

      Now I must use this.
      ds.Tables["Panel"]
      The table is called 'Panel'. I cannot find it, not public. However.
      Can I change this, maybe another call from xsd?

     Name= 'Order'
     Name= 'CurrentProduct'
     Name= 'Panels'
     Name= 'Panel'
    DataSet ds = new DataSet();
    ds.ReadXml(@"..\..\Data\CurrentOrder.xml");
    
    foreach (DataTable item in ds.Tables)
    {
    	Trace.WriteLine($"Name= '{item.TableName}'");
    }  
    
    
    IEnumerable<DataRow> panelQuery = from panel in ds.Tables["Panel"].AsEnumerable() select panel;
    <Order station="111111" task="00007" currentPanelNo="5">
      <CurrentProduct product="AirCondition" indices="7" LB="true" />
      <Panels>
        <Panel packageNo="aaa" no="5" timeInput="2018-12-12 13:02:52" timeOutput="2018-12-12 13:02:54" >
          <Sides>
            <Side no="1">

    All is not working. Why?
    var qry = from a in ds.Tables["Panel"].AsEnumerable()
    		  where (a.Field<Int32>("no") == 5)
    		  select new
    		  {
    			  packageNo = a.Field<Int32>("packageNo")
    		  };
    
    // var qry2 = from DataRow row in ds.Tables["Panel"].Rows select row["ColumnName"]).ToList();
    
    IEnumerable<DataRow> panelQuery =  from panel in ds.Tables["Panel"].AsEnumerable() select panel;
    
    IEnumerable<DataRow> panelRows = panelQuery.Where(p => p.Field<int>("no") == 5);
    
    
    var tt =  ds.Tables["Panel"].AsEnumerable().Where(p => p.Field<int>("no") == "5").FirstOrDefault();
    <Order station="111111" task="00000007" currentPanelNo="5">
      <CurrentProduct product="Test 2" indices="9" LB="true" />
      <Panels>
        <Panel packageNo="aaa" no="5" timeInput="2018-12-12 13:42:52" timeOutput="2018-12-12 13:44:54" IsExcecuted="Done">
      ....
        </Panel>
      </Panels>
    </Order>

    Regards Markus



    Wednesday, December 12, 2018 6:00 PM

Answers