jump to navigation

Namespace prefix ‘ns1’ is not defined. XMLDocument June 17, 2016

Posted by juanpablo1manrique in SharePoint.
Tags: , ,
add a comment

Para solucionar este toca agregar todos los namespaces del mensaje

 

XmlNamespaceManager nsm = new XmlNamespaceManager(new NameTable());

nsm.AddNamespace(“SOAP-ENV”, “http://schemas.xmlsoap.org/soap/envelope/”);
nsm.AddNamespace(“ns1”, “http://schemas.xmlsoap.org/wsdl/soap/”);
nsm.AddNamespace(“xsd”, “http://www.w3.org/2001/XMLSchema”);
nsm.AddNamespace(“xsi”, “http://www.w3.org/2001/XMLSchema-instance”);
nsm.AddNamespace(“SOAP-ENC”, “http://schemas.xmlsoap.org/soap/encoding/”);
nsm.AddNamespace(“ns2”, “http://xml.apache.org/xml-soap”);
nsm.AddNamespace(“ns3”, “http://www.example.org/myns/”);

XmlNode node = xdoc.SelectSingleNode(“/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:metodo1/return/property1”,nsm);

 

Saludos

PD. Recomendado

http://www.freeformatter.com/xpath-tester.html#ad-output

 

Errores relacionados

‘XElement’ does not contain a definition for ‘XPathSelectElements’ and no extension method ‘XPathSelectElements’ accepting a first argument of type ‘XElement’ could be found (are you missing a using directive or an assembly reference?