End Google Ads 201810 - BS.net 01 --> this taken from another forum i'm on, however they dont seem to have an answer.It is 2 posts i have put into this 1 post to show the progression.

POST 1

Hello, i'm trying to create an XML database to hold names.

It's for a game based on film making. I have 3 forms 1 main form 1 for naming the film 1 for archives (to view what films you have made in the past)

Basically in the name the film form you add the name into a text box, to avoid using a database orginally as i don't understand them fully i used a list.

NAMING FORM
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Pmanager
{
public partial class Shoot : Form
{
string moviename;
public List FilmNames = new List();

public Shoot()
{
InitializeComponent();

}

private void textBox1_TextChanged(object sender, EventArgs e)
{
moviename = textBox1.Text;


}

private void button1_Click(object sender, EventArgs e)
{
listmethod();
foreach (string Item in FilmNames)
{
MessageBox.Show(Item + "\r\n"); // put this in to check if the list was storing between forms
}

}

public void listmethod()
{

FilmNames.Add(moviename);

}
}
}


ARCHIVES
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Pmanager
{
public partial class Archieves : Form
{
Shoot shoot = new Shoot();
public Archieves()
{
InitializeComponent();
}

private void Archieves_Load(object sender, EventArgs e)
{

}

private void textBox1_TextChanged(object sender, EventArgs e)
{
foreach (string Item in shoot.FilmNames)
{
textBox1.Text += Item + "\r\n";
}

}


}
}

However it became apparent that why i try to view this list in the archives it wont store the data and writes over it because I am recalling it. So I believe I need a database. I chose to use XML as i dont seem to understand sql to well

in my program main I'm creating a new XML database, this works fine. But i'm not really sure how to store the film names from the txtbox input in naming and displaying in archives.

So I'm unsure where to go, documentation I've looked at doesn't really give an indication, so if anyone could help or if there is a way of storing the list between forms it would be much appreciated.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Xml;
namespace Pmanager
{
static class Program
{
/// /// The main entry point for the application.
/// [STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
XmlTextWriter xmlWriter = new XmlTextWriter("database.xml", System.Text.Encoding.UTF8);
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
xmlWriter.WriteStartElement("Root");
xmlWriter.Close();
}
}
}


POST 2

Ok so i started working on xml databases and I got one working that both writes and reads, However it will only write or read 1 field and any added fields on top will overwrite the preceding one.I know this is because I am asking it to only write 1 xml string "ID" so i tried to add a list into the equation and now i'm fully stuck.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
string ID = ("ID");


public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
XmlTextReader reader = new XmlTextReader(Application.StartupPath + @"\\xmldata.xml");
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Text:
textBox2.Text = reader.Value;
break;

}
}
}

private void button1_Click(object sender, EventArgs e)
{
string sStartupPath = Application.StartupPath;
XmlTextWriter objXmlTextWriter = new XmlTextWriter(sStartupPath + @"\\xmldata.xml", null);
objXmlTextWriter.Formatting = Formatting.Indented;
objXmlTextWriter.WriteStartDocument();
objXmlTextWriter.WriteStartElement(ID);
objXmlTextWriter.WriteString(textBox1.Text);
objXmlTextWriter.WriteEndElement();
objXmlTextWriter.WriteEndDocument();
objXmlTextWriter.Flush();
objXmlTextWriter.Close();
}

private void textBox2_TextChanged(object sender, EventArgs e)
{

}

}
}