Arcturus Gonzalez
Arcturus Gonzalez

Reputation: 1

SelectSingleNode and InnerText in XML file

I have the following code:

if (doc.DocumentElement.Name == "SOAP-ENV:Envelope")
   {
    string xmlEnv = doc.DocumentElement.InnerXml;
    doc.LoadXml(xmlEnv);
    if (doc.DocumentElement.Name == "SOAP-ENV:Body")
    {
     string xmlBody = doc.DocumentElement.InnerXml;
                    doc.LoadXml(xmlBody);
                    if (doc.DocumentElement.Name == "NS1:RecebeMensagemResponse")
                    {
                        foreach (XmlNode ns1 in doc)
                        {
                            **sldfinl = doc.SelectSingleNode("//SldFinl").InnerText;**
                            dthrbc = doc.SelectSingleNode("//DtHrBC").InnerText;
                            dtmovto = doc.SelectSingleNode("//DtMovto").InnerText;

And I have the following information in my XML. The first line in bold in the code above ( sldfinl = doc.SelectSingleNode("//SldFinl").InnerText;) is returning null but what I'm looking for is in XML below in bold(<SldFinl>2000437760.49</SldFinl>)

-<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

-<SOAP-ENV:Body xmlns:NS1="urn:JDSPBCAB_Intf-IJDSPBCAB" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

-NS1:RecebeMensagemResponse

ALS99

JDCCAB00000000025309

38166

60814191

BMB202103105

STR0014R1

20210310093440

R

STR0014R1<NumCtrlIF_LDL>BMB202103105</NumCtrlIF_LDL><ISPBIF_LDL>60814191</ISPBIF_LDL>2021-03-10T07:30:002000437760.49<Grupo_STR0014R1_Lanc>STR0007R1<NumCtrlIF_LDLOr>01000841321009075999</NumCtrlIF_LDLOr>60701190STR202103100330260052021-03-10T09:30:41<TpDeb_Cred>D</TpDeb_Cred>9.50</Grupo_STR0014R1_Lanc>2000437750.992021-03-10T09:34:222021-03-10

<Numero_Mensagem xsi:type="xsd:string">28800</Numero_Mensagem>

</NS1:RecebeMensagemResponse>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope> and the program is returning -> System.Xml.XmlNode.SelectSingleNode(...) returned null.

Am I missing something?

Thank you in advance

Arcturus

Upvotes: 0

Views: 428

Answers (0)

Related Questions