I know C# but have not worked with anything XML before. I need to delete some nodes from a XML file. Below, the content of the file is shown partially.
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:oxml="http://www.idontk.now/cove/ws/oxml/">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.blahblah.org/wss/2001/02/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>HJNVB</wsse:Username>
<wsse:Password Type="http://docs.beatles.com/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">AMts</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<oxml:solicitarRecibirCoveServicio>
<oxml:comprobantes>
<oxml:tipoOperacion>1234</oxml:tipoOperacion>
<oxml:patenteAduanal>1234</oxml:patenteAduanal>
<oxml:fechaExpedicion>2019-03-19</oxml:fechaExpedicion>
<oxml:rfcConsulta>BEATLES1234</oxml:rfcConsulta>
<oxml:tipoFigura>1</oxml:tipoFigura>
<oxml:correoElectronico>undis@closed.nah</oxml:correoElectronico>
<oxml:firmaElectronica>
<oxml:certificado>AugAw</oxml:certificado>
<oxml:cadenaOriginal>|1234|</oxml:cadenaOriginal>
<oxml:firma>12341234</oxml:firma>
</oxml:firmaElectronica>
I need to find and then delete the oxml:certificado node, located inside the oxml:firmaElectronica node which is the last node shown on my sample XML code.
I am trying to find the oxml:certificado node with this C# code:
XmlNode certificado = doc.SelectSingleNode("/soapenv:Envelope/soapenv:Body/oxml:solicitarRecibirCoveServicio/oxml:comprobantes/oxml:firmaElectronica/oxml:certificado");
But I get the following error:
An unhandled exception of type 'System.Xml.XPath.XPathException' occurred in System.Xml.dll Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.
Any help on finding and deleting this node would be great. Thanks.