How-do-you-do,

Given the xml file and asp.cyberspace code:

Code:

<?xml version="i.0" standalone="yes"?> <Logs>   <Indexer>     <keyword>books</keyword>     <url>www1</url>     <occurence>1</occurence>   </Indexer>   <Indexer>     <keyword>stone</keyword>     <url>www2</url>     <occurence>one</occurence>   </Indexer>   <Indexer>     <keyword>tape</keyword>     <url>www3</url>     <occurence>1</occurence>   </Indexer>   <Indexer>     <keyword>home</keyword>     <url>www4</url>     <occurence>i</occurence>   </Indexer>   <Indexer>     <keyword>sand</keyword>     <url>www5</url>     <occurence>1</occurence>   </Indexer>   <Indexer>     <keyword>books</keyword>     <url>www6</url>     <occurence>1</occurence>   </Indexer>   <Indexer>     <keyword>price</keyword>     <url>www7</url>     <occurence>one</occurence>   </Indexer>   <Indexer>     <keyword>books</keyword>     <url>www8</url>     <occurence>1</occurence>   </Indexer>   <Indexer>     <keyword>record</keyword>     <url>www9</url>     <occurence>1</occurence>   </Indexer>   <Indexer>     <keyword>jeans</keyword>     <url>www10</url>     <occurence>1</occurence>   </Indexer>   <Indexer>     <keyword>rail</keyword>     <url>www11</url>     <occurence>ane</occurence>   </Indexer>   <Indexer>     <keyword>price</keyword>     <url>www12</url>     <occurence>one</occurence>   </Indexer> </Logs>

asp.internet code Code:

                
  1. protected void Page_Load(object sender, EventArgs e)

  2.     {

  3.          DataSet ds = new DataSet("Logs");

  4.          cord[] words ={"books", "rock","tape","home","sand","books",

  5.                            "price", "books","tape","jeans","rail",

  6.                            "price"};

  7.         string[] url = {"www1","www2","www3","www4","www5",

  8.                         "www6","www7","www8","www9","www10",

  9.                         "www11","www12"};

  10.         DataTable dt = new DataTable("Indexer");

  11.         DataColumn col1 = new DataColumn("keyword");

  12.         DataColumn col2 = new DataColumn("url");

  13.         DataColumn col3 = new DataColumn("occurence");

  14.         dt.Columns.AddRange(new DataColumn[] { col1, col2, col3 });

  15.         DataColumn[] pri = new DataColumn[i];  //set principal key

  16.         pri[0] = dt.Columns[0];

  17.         dt.PrimaryKey = pri;

  18.         for (int i = 0; i < words.Length; i++)

  19.         {

  20.             //DataRow dr = dt.Rows.Detect(words[i]);

  21.             //if (dt.Rows.Count > 0)

  22.             //{

  23.                 //foreach (DataRow dr in dt.Rows)

  24.                 //{

  25.                 //    if ((cord)(dr["keyword"]) != words[i])

  26.                 //    {

  27.                         DataRow dr2 = dt.NewRow();

  28.                         dr2["keyword"] = words[i];

  29.                         dr2["URL"] = url[i];

  30.                         dr2["occurence"] = i;

  31.                         dt.Rows.Add(dr2);

  32.                 //    }

  33.                 //}//end foreach

  34.             //}

  35.        }//end for loop

  36.         //bind the dataset to the gridview and salve to xml file

  37.         ds.Tables.Add(dt);

  38.         this.GridView1.DataSource = ds.Tables["Indexer"].DefaultView;

  39.         this.GridView1.DataBind();

  40.         ds.WriteXml(@"c:\sampleData.xml");

  41.     }

  42. }


How do i change the asp.net lawmaking so that if the same keyword in the datatable is found it volition change value of occurence past calculation 1 instead of calculation another element with the same keyword?

Notation: How practise I trap if the data table has a primary key?
or a data table has no main cardinal?

My instance sets the starting time cavalcade as a primary primal

If the datatable has been successfully updated, the right output (xml file) or gridview should be similar this..

Lawmaking:

<?xml version="1.0" standalone="yes"?> <Logs>   <Indexer>     <keyword>books</keyword>     <url>www1</url>     <occurence>3</occurence>   </Indexer>   <Indexer>     <keyword>rock</keyword>     <url>www2</url>     <occurence>1</occurence>   </Indexer>   <Indexer>     <keyword>record</keyword>     <url>www3</url>     <occurence>2</occurence>   </Indexer>   <Indexer>     <keyword>home</keyword>     <url>www4</url>     <occurence>1</occurence>   </Indexer>   <Indexer>     <keyword>sand</keyword>     <url>www5</url>     <occurence>1</occurence>   </Indexer>   <Indexer>     <keyword>price</keyword>     <url>www7</url>     <occurence>two</occurence>   </Indexer>   <Indexer>     <keyword>jeans</keyword>     <url>www10</url>     <occurence>1</occurence>   </Indexer>   <Indexer>     <keyword>track</keyword>     <url>www11</url>     <occurence>1</occurence>   </Indexer>  </Logs>

Promise my queries are clear...

Greg