XMLNodeList to HTML Table based on Ektron Smartform data


/ Published in: C#
Save to your folder(s)

Ektron smartform data contains a xml nodelist which I put in a data table and parse out into an html table


Copy this code and paste it in your HTML
  1. XmlNodeList floorplans = xmlDoc.SelectNodes("/Property/Floorplans/Floorplan");
  2. numberOfRooms = floorplans.Count;
  3.  
  4. DataTable dtRooms = new DataTable();
  5. dtRooms.Columns.Add("roomType");
  6. dtRooms.Columns.Add("Level");
  7. dtRooms.Columns.Add("Dimensions");
  8.  
  9.  
  10. for (int i = 0; i < floorplans.Count; i++)
  11. {
  12. try
  13. {
  14. XmlNode roomNode = floorplans.Item(i);
  15.  
  16. string roomType = floorplans[i].Attributes["UnitType"].InnerText;
  17. string level = floorplans[i].Attributes["Level"].InnerText;
  18. string Dimensions = floorplans[i].InnerText;
  19. dtRooms.Rows.Add(roomType, level, Dimensions);
  20. }
  21. catch (NullReferenceException e)
  22. {
  23. roomError.Text = e.Message;
  24. }
  25.  
  26.  
  27. }
  28.  
  29. repeaterRooms.DataSource = dtRooms;
  30. repeaterRooms.DataBind();

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.