I have an XML file like this:
<?xml version="1.0" encoding="UTF-8"?>
<Message>
<MessageId>
<ServiceId>SolicitaLogon</ServiceId>
<Version>1.0</Version>
<MsgDesc>Solicitação do Desafio de Logon</MsgDesc>
<Code>200601001987</Code>
<FromAddress>TJ</FromAddress>
<ToAddress>PGE</ToAddress>
<Date>2011-10-20</Date>
</MessageId>
<MessageBody>
<Resposta>
<Mensagem>
<Codigo>0</Codigo>
<Descricao>Mensagem processada com sucesso</Descricao>
</Mensagem>
<Desafio>4557830751418350620</Desafio>
</Resposta>
</MessageBody>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
</Signature>
</Message>
I want to read this file by discarding what is between the response tag. I'm doing this, I appreciate it if there is a better way:
//carrega o mesmo arquivo, e adiciona o desafio criptografado
XmlDocument x = new XmlDocument();
string CaminhoCompletoArquivoConfirmacao = PathPadrao + "confirmaLogon.xml";
x.Load(CaminhoCompletoArquivoConfirmacao);
var todosOsNos = x.SelectNodes("//*");
for (int i = 0; i < todosOsNos.Count; i++)
{
var element = todosOsNos[i];
string ElementoCompleto = element.Name + element.InnerText;
if (element.Name == "Resposta" && element.Name == "Mensagem" && element.Name != "Codigo" && element.Name != "Descricao")
{
EscreveXMLIndividual(ElementoCompleto, "ConfirmaLogonNovo.xml");
}
}