How about loading the XML into a dataset and then manipulating the dataset and rebinding?
Instead of using the XML file and binding that to the listbox, try this: (source)
string myXMLfile = "C:\\MySchema.xml";
DataSet ds = new DataSet();
try
{
//reads file and loads data into dataset
ds.ReadXml(myXMLfile);
//set the listbox's datasource to the dataset
//note that if you have complex XML then you might need to set this to one of the datatables in the datset to get what you want
listBox1.DataSource = ds;
listBox1.DataBind();
}
catch (Exception ex)
{
//Handle error
}
Lets assume you XML is rather simple. To add a tow to the DataSet you would do: (source)
//if customers is the name of your table (have not seen your XML)
DataRow newCustomersRow = ds.Tables["Customers"].NewRow();
newCustomersRow["CustomerID"] = "ALFKI";
newCustomersRow["CompanyName"] = "Alfreds Futterkiste";
dataSet1.Tables["Customers"].Rows.Add(newCustomersRow);
Here is an XML example that should work with the above:
<Data>
<Customers>
<Customer>
<CustomerID>123</CustomerID>
<CompanyName>Name</CompanyName>
</Customer>
</Customers>
</Data>
I have not compiled or tried to run any of that, but you should get the general idea and adapt it to your code.