I need to assign the value of an element of an XML document to a variable, specifically the value of the name element Clave
, I wrote this but it does not work since it does not find the node because the function does not return any value. ..what am I doing wrong ... ??
public string ValoresCamposXml(XmlDocument documentoXml)
{
string valores = string.Empty;
XmlNode nodo = documentoXml.SelectSingleNode("//Clave");
valores = nodo.InnerText;
return valores;
}
this is the xml document:
<?xml version="1.0" encoding="UTF-8"?>
-<FacturaElectronica xmlns="https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/facturaElectronica" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Clave>50627031800310140886100100001010000000003112465302</Clave>
<NumeroConsecutivo>00100001010000000003</NumeroConsecutivo>
<FechaEmision>2018-03-27T08:00:20-04:00</FechaEmision>
-<Emisor>
<Nombre>TECNOLOGIAS SA</Nombre>
-<Identificacion>
<Tipo>02</Tipo>
<Numero>310rty14088uyt61</Numero>
</Identificacion>
<NombreComercial>TECNOLOGIAS SA</NombreComercial>
-<Ubicacion>
<Provincia>1</Provincia>
<Canton>02</Canton>
<Distrito>01</Distrito>
<Barrio>01</Barrio>
<OtrasSenas>CENTRO CORPORATIVO PLAZA ROBLE EDIFICIO LAS TERRAZAS 5TO PISO</OtrasSenas>
</Ubicacion>
-<Telefono>
<CodigoPais>506</CodigoPais>
<NumTelefono>40701540</NumTelefono>
</Telefono>
-<Fax>
<CodigoPais>506</CodigoPais>
<NumTelefono>40701540</NumTelefono>
</Fax>
<CorreoElectronico>[email protected]</CorreoElectronico>
</Emisor>
</FacturaElectronica>