Advertisement
Guest User

Untitled

a guest
Apr 25th, 2014
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <kdd>
  3. <Table>
  4. <robel ID="1">
  5. <groof NAME="GOBS-1">
  6. <sintal ID="A">Cynthia1</sintal>
  7. <sintal ID="B">Sylvia2</sintal>
  8. <sintal ID="C">Sylvia3</sintal>
  9. <sintal ID="D">Sylvia4</sintal>
  10. </groof>
  11. <groof NAME="GOBS-2">
  12. <sintal ID="A">Cynthia1</sintal>
  13. <sintal ID="B">Cynthia2</sintal>
  14. <sintal ID="C">Cynthia3</sintal>
  15. <sintal ID="D">Cynthia4</sintal>
  16. </groof>
  17. <groof NAME="GOBS-3">
  18. <sintal ID="A">Daniella1</sintal>
  19. <sintal ID="B">Daniella2</sintal>
  20. <sintal ID="C">Daniella3</sintal>
  21. <sintal ID="D">Daniella4</sintal>
  22. </groof>
  23. </robel>
  24. </Table>
  25. </kdd>
  26.  
  27. foreach (XElement element in doc.Descendants("groof"))
  28. {
  29. string mmname = element.Attribute("NAME").Value.ToString();
  30.  
  31. if (mmname == "GOBS-2")
  32. {
  33. bool found = false;
  34. foreach (XElement element1 in doc.Descendants("sintal"))
  35. {
  36.  
  37. if (found == false)
  38. {
  39. string CurrentValue = (string)element1;
  40. if ("Cynthia1" == CurrentValue)
  41. {
  42. try
  43. {
  44. //do something
  45. found = true;
  46. }
  47. catch (Exception e)
  48. {
  49. }
  50. }
  51. }
  52. }
  53. }
  54.  
  55. XElement cynthia = doc
  56. .Descendants("groof")
  57. .Where(g => g.Attribute("NAME").Value == "GOBS-2")
  58. .Elements("sintal")
  59. .Where(s => s.Value == "Cynthia1")
  60. .Single();
  61.  
  62. foreach (XElement element in doc.Descendants("groof"))
  63. {
  64. string mmname = element.Attribute("NAME").Value.ToString();
  65.  
  66. if (mmname == "GOBS-2")
  67. {
  68. bool found = false;
  69. foreach (XElement element1 in element.Descendants("sintal"))
  70. {
  71.  
  72. if (found == false)
  73. {
  74. string CurrentValue = (string)element1;
  75. if ("Cynthia1" == CurrentValue)
  76. {
  77. try
  78. {
  79. //do something
  80. found = true;
  81. }
  82. catch (Exception e)
  83. {
  84. }
  85. }
  86. }
  87. }
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement