[/ u] raquo ;, } );
TEXT=TEXT.Replace ( [i] raquo ;, { i ). Replace ( [/ i] raquo ;, } );
TEXT=TEXT.Replace ( r n raquo ;, par );
TEXT=string.Concat (TEXT, r n} );
return TEXT;
}
}
private static string SEARCH_BOX_DEFTEXT;
private static string MAINFORM_HEAD_TEXT;
private static ListBox listbox=new ListBox ();
private static Hashtable HASH=new Hashtable ();
public static Hashtable GETHASH
{
get {return main_form.HASH; }
}
private static string PATH= raquo ;;
/// lt; summary gt;
/// Повертає або задає ім'я файлу для завантаження і збереження XML.
/// lt;/summary gt;
public static string XMLPATH
{
get {return main_form.PATH; }
set
{
if (value!= )
if (! File.Exists (value))
{
XmlTextWriter writer=new XmlTextWriter (File.Create (value), Encoding.UTF8);
writer.WriteStartDocument ();
writer.WriteStartElement ( hashtable );
writer.WriteStartAttribute ( pair_count );
writer.WriteEndAttribute ();
writer.WriteEndElement ();
writer.Close ();
}
main_form.PATH=value;
}
}
private void GetAllNodes (ToolStripDropDownButton dropdown)
{
dropdown.DropDownItems.Clear ();
foreach (object O in HASH.Keys)
{
dropdown.DropDownItems.Add (O.ToString ());
}
if (dropdown.DropDownItems.Count gt; 0)
dropdown.Enabled=true;
}
public static void LoadXML (string path)
{
XmlDocument document=new XmlDocument ();
FileStream stream=new FileStream (path, FileMode.Open);
try
{
document.Load (stream);
stream.Close ();
}
catch (XmlException)
{
stream.Close ();
XmlTextWriter writer=new XmlTextWriter (path, Encoding.UTF8);
writer.WriteStartDocument ();
writer.WriteStartElement ( hashtable );
writer.WriteStartAttribute ( pair_count );
writer.WriteEndAttribute ();
writer.WriteEndElement ();
writer.Close ();
stream=new FileStream (path, FileMode.Open);
document.Load (stream);
stream.Close ();
}
XmlNodeList list=document.GetElementsByTagName ( pair );
if (list.Count gt; 0) HASH.Clear ();
for (int i=0; i lt; list.Count; i ++)
{
HASH.Add (list [i] .ChildNodes [0] .InnerText, list [i] .ChildNodes [1] .InnerText);
}
}
public static void SaveXML (string path)
{
object [] keys=new object [HASH.Count];
HASH.Keys.CopyTo (keys, 0);
XmlTextWriter writer=new XmlTextWriter (path, Encoding.UTF8);
writer.WriteStartDocument ();
writer.WriteStartElement ( hashtable );
writer.WriteStartAttribute ( pair_count );
writer.WriteEndAttribute ();
writer.WriteEndElement ();
writer.Close ();
XmlDocument document=new XmlDocument ();
document.Load (path);
for (int i=0; i lt; HASH.Count; i ++)
{
XmlElement pair=document.CreateElement ( pair );
XmlAttribute pair_id=document.CreateAttribute ( id );
pair_id.Value=(i + 1) .ToString ();
pair.Attributes.Append (pair_id);
XmlElement key=document.CreateElement ( key );
key.InnerText=keys [i] .ToString ();
pair.AppendChild (key);
XmlElement value=document.CreateElement ( value );
value.InnerText=HASH [keys [i]]. ToString ();
pair.AppendChild (value);
document.DocumentElement.AppendChild (pair);
}
if (document.DocumentElement.HasChildNodes)
document.DocumentElement.Attributes [ pair_count ]. Value=document.DocumentElement.ChildNodes.Count.ToString ();
document.Save (path);
}
public static string AddXMLNode (string add_key, string add_value)
{
try
{
HASH.Add (add_key, add_value);
}
catch (ArgumentException)
{
return стаття не додана: r nКлюч вже присутній в Хеш-таблиці raquo ;;
}
catch (Exception err)
{
return стаття не додана r nСообщеніе: r n + Err.Message;
}
if (! File.Exists (XMLPATH))
{
XmlTextWriter writer=new XmlTextWriter (XMLPATH, Encoding.UTF8);
writer.WriteStartDocument ();
writer.WriteStartElement ( hashtable );
...