Advertisement
Guest User

XML for SOURAB002

a guest
Jan 27th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Xml;
  11. using System.Xml.Linq;
  12.  
  13. namespace PostcodeTest
  14. {
  15. public partial class Form1 : Form
  16. {
  17. public Form1()
  18. {
  19. InitializeComponent();
  20. }
  21.  
  22. private void btnGenerateXML_Click(object sender, EventArgs e)
  23. {
  24.  
  25. XmlDocument xD = new XmlDocument();
  26.  
  27. using (CRMDEVEntities context = new CRMDEVEntities())
  28. {
  29.  
  30. XDocument doc = new XDocument();
  31. XElement Root = new XElement("Root");
  32.  
  33. doc.Add(Root);
  34.  
  35. var OpportunitiesWithLatAndLong = from o in context.vListOpportunities
  36. join p in context.outcodepostcodes
  37. on o.oppo_secu_postcode.Substring(0, 4) equals p.outcode
  38. where o.oppo_casenumber.StartsWith("15")
  39. select new { o, p };
  40.  
  41. foreach (var OpportunityWithLatAndLong in OpportunitiesWithLatAndLong)
  42. {
  43. XElement Header = new XElement("Casenumber" + OpportunityWithLatAndLong.o.oppo_casenumber,
  44. new XElement("Lat", OpportunityWithLatAndLong.p.lat),
  45. new XElement("Long", OpportunityWithLatAndLong.p.lng)
  46. );
  47. Root.Add(Header);
  48. }
  49.  
  50. txtXMLOutput.Text = doc.ToString();
  51.  
  52.  
  53. }
  54.  
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement