anchor.diff:              | "LinearLayout" when reader.NodeType = XmlNodeType.EndElement -> 
                   appendXaml <| "\n" + depthTab + "</StackPanel>"
               | "TextView" -> 
  -                let textSize = getNumber(reader.GetAttribute("textSize"))
  -                appendXaml <| "\n" + depthTab + "<TextBlock Text=\"" + reader.GetAttribute("text") + "\" HorizontalAlignment=\"Center\" FontSize=\"" + textSize + "\"/>"
  +                let textSize = getNumber(tryGetAttribute name "textSize")
  +                appendXaml <| "\n" + depthTab + "<TextBlock Text=\"" + (tryGetAttribute name "text") + "\" HorizontalAlignment=\"Center\" FontSize=\"" + textSize + "\"/>"
               | "EditText" ->
  -                appendXaml <| "\n" + depthTab + "<TextBox x:Name=\"" + reader.GetAttribute("id") + "\" IsReadOnly=\"False\" MinWidth=\"250\" HorizontalAlignment=\"Center\" />"
  +                appendXaml <| "\n" + depthTab + "<TextBox x:Name=\"" + (tryGetAttribute name "id") + "\" IsReadOnly=\"False\" MinWidth=\"250\" HorizontalAlignment=\"Center\" />"
               | "Button" -> 
  -                let name = reader.GetAttribute("id")
  -                let textSize = getNumber(reader.GetAttribute("textSize"))
  -                if actions.Contains(name) then
  +                let name = tryGetAttribute name "id"
  +                let textSize = getNumber(tryGetAttribute name "textSize")
  +                if actions.ContainsKey(name) then
                       let click = name + "Click"
  -                    appendXaml <| "\n" + depthTab + "<Button Name=\"" + name + "\" HorizontalAlignment=\"Center\" Click=\"" + click + "\" FontSize=\"" + textSize + "\" Content=\"" + reader.GetAttribute("text") + "\"> </Button>"
  +                    appendXaml <| "\n" + depthTab + "<Button Name=\"" + name + "\" HorizontalAlignment=\"Center\" Click=\"" + click + "\" FontSize=\"" + textSize + "\" Content=\"" + (tryGetAttribute name "text") + "\"> </Button>"
                       appendAdditions <| "\nprivate void " + click + "(object sender, RoutedEventArgs e)\n{"
                       appendAdditions <| (actions.Item(name) :?> string)
                       appendAdditions <| "\n}"
  +                    if actionsAdditions.ContainsKey(name) then
  +                        appendAdditions <| (actionsAdditions.Item(name) :?> string)
                   else 
  -                    appendXaml <| "\n" + depthTab + "<Button Name=\"" + name + "\" HorizontalAlignment=\"Center\" FontSize=\"" + textSize + "\" Content=\"" + reader.GetAttribute("text") + "\"> </Button>"
  +                    appendXaml <| "\n" + depthTab + "<Button Name=\"" + name + "\" HorizontalAlignment=\"Center\" FontSize=\"" + textSize + "\" Content=\"" + (tryGetAttribute name "text") + "\"> </Button>"
               | "ImageView" -> 
  -                let url = reader.GetAttribute("src") 
  +                let url = tryGetAttribute name "src"
                   let fileName = "image" + string imageCounter + url.Substring(url.Length - 4, 4)
                   let fullFileName = path + "\\" + fileName
                   download fullFileName url
                   appendXaml <| "\n" + depthTab + "<Image Source=\"" + fileName + "\" />"
                   imageCounter <- imageCounter + 1
  -                append resources <| "\n<Resource Include=\"" + fileName + "\" />" 
  +                if not (resources.ContainsKey(fileName)) then
  +                    append resourcesBuilder <| "\n<Resource Include=\"" + fileName + "\" />"
  +                    resources.Add(fileName, referencesBuilder.ToString()) 
               | "WebView" -> 
  -                let name = reader.GetAttribute("id")
  +                let name = tryGetAttribute name "id"
                   appendXaml <| "\n" + depthTab + "<phone:WebBrowser x:Name=\"" + name + "\" IsScriptEnabled=\"True\" Height=\"763\" Width=\"475\" />"
  -                appendConstructor <| "\n" + name + ".Navigate(new Uri(\"" + reader.GetAttribute("url") + "\", UriKind.RelativeOrAbsolute));"
  +                appendConstructor <| "\n" + name + ".Navigate(new Uri(\"" + (tryGetAttribute name "url") + "\", UriKind.RelativeOrAbsolute));"
               | "Map" ->
  -                let name = reader.GetAttribute("id")
  +                let name = tryGetAttribute name "id"
                   appendXaml <| "\n" + depthTab + "<maps:Map Name=\"" + name + "\" HorizontalAlignment=\"Stretch\" VerticalAlignment=\"Stretch\"
               ScaleVisibility=\"Visible\"
               Height=\"768\"
  
positive.code:             | _ -> ()
  
          with | :? XmlException as e ->
              failwithf "Error while parsing %s: %s" path e.Message
  
      reader.Close()
  
  
negative.code: }"
  
              | "save-session" -> 
                  append currentAdditionsBuilder <| "\nprivate string sessionId;"
                  builderAppend <| "\nint semicolonPos = result.IndexOf(';');
  sessionId = result.Substring(semicolonPos + 1, result.Length - semicolonPos - 1);"
              | "patients-request" -> builderAppend <| "\nWebClient data = new WebClient();
  data.DownloadStringCompleted += new DownloadStringCompletedEventHandler(getResponse);
  data.DownloadStringAsync(new Uri(\"" + (tryGetAttribute name "url") + "\"));"
              // разбор строки patients и выставление пациентов на карте
              | "showmap" ->
                  if not (references.ContainsKey("mapsReferences")) then
                      append referencesBuilder <| "\n<Reference Include=\"Microsoft.Phone.Controls.Maps, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e, processorArchitecture=MSIL\" />
  <Reference Include=\"System.Device\" />
  <Reference Include=\"System.Servicemodel\" />"
                      references.Add("mapsReferences", referencesBuilder.ToString())
                  if not (xmlns.ContainsKey("mapsXmlns")) then
                      append xmlnsBuilder <| "\nxmlns:maps=\"clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps\""
                      xmlns.Add("mapsXmlns", xmlnsBuilder.ToString())
                  if not (usings.ContainsKey("mapsUsings")) then
                      append usingsBuilder <| "\nusing Microsoft.Phone.Controls.Maps;
  using System.Device.Location;"
                      usings.Add("mapsUsings", usingsBuilder.ToString())
                  builderAppend <| "\nint count = 0;
  int length = patients.Length;
  StringBuilder latitude = new StringBuilder();
  