[Resolvido] Alterar valor de um Elemento Xml
Preciso de alterar o valor dos elementos no meu xml. So que o problema e que o código não esta alterando nenhum valor dentro da tag do meu xml. Meu xml esta assim e queria estar alterando os itens apos Rota
<Planilha Rota="Nome da rota" Funcionario="" SaidaP="0" VoltaP="0" Deposito="R$ 0,00" Gasto="R$ 0,00" Cheque="R$ 0,00" Moeda="R$ 0,00" Falta="R$ 0,00" Sobra="R$ 0,00" Observacoes="" />
Código que estou trabalhando e esse
public static void EditarPlanilhaLp(Listarplanilhas Rota, string nArchive)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(@"cache\" + nArchive + ".xml");
XmlElement mapElement = (XmlElement)xmlDoc.SelectSingleNode(@"//Planilha[@Rota='" + Rota + "']");
if (mapElement != null)
{
mapElement.Attributes["Funcionario"].Value = Rota.LpGridFunc;
mapElement.Attributes["SaidaP"].Value = Rota.LpGridSaiu;
mapElement.Attributes["VoltaP"].Value = Rota.LpGridVolta;
mapElement.Attributes["Deposito"].Value = Rota.LpGridDep;
mapElement.Attributes["Gasto"].Value = Rota.LpGridGast;
mapElement.Attributes["Cheque"].Value = Rota.LpGridCheq;
mapElement.Attributes["Moeda"].Value = Rota.LpGridMoed;
mapElement.Attributes["Falta"].Value = Rota.LpGridFalt;
mapElement.Attributes["Sobra"].Value = Rota.LpGridSob;
mapElement.Attributes["Observacoes"].Value = Rota.LpObs;
}
xmlDoc.Save(@"cache\" + nArchive + ".xml");
}Discussão (2)
Carregando comentários...