This discussion is archived
1 Reply Latest reply: Nov 27, 2012 6:44 AM by Michel RSS

FindNode returning Null And XML Not Accepting Special Characters

agnel p Newbie
Currently Being Moderated
Hi All,

i am trying the get the attribute value in the element "ns4:InfoCFDi" using FindNode method, but the method is returning NULL. I used the same code for other sample as well and was successfull. but for this specific XML file(which is below) I am getting a Null.

i can get till S:Body, but when i try to use FindNode for ":Body/s4:ResponseGeneraCFDi" I get Null value.
And I used "S:Body/*[local-name()=" | "ns4:ResponseGeneraCFDi" | "]";
as mentioned in other post but still no success.

==>I Have one more question relating to special characters. I need to use characters such as - ó in my XML to read as well as write. When I try to read i am getting XML parse error and when writing, i cannot open the file properly.

Your help is much appreciated.

My code is here:
/**************/
Local XmlDoc &inXMLDoc, &reqxmldoc;
Local XmlNode &RecordNode;

&inXMLDoc = CreateXmlDoc();
&ret = &inXMLDoc.ParseXmlFromURL("D:\Agnel\Mexico Debit Memo\REALRESPONSE.xml");
If &ret Then

&RecordNode = &inXMLDoc.DocumentElement.FindNode("" );
If &RecordNode.IsNull Then
Warning MsgGet(0, 0, "Agnel FindNode not found.");
rem MessageBox(0, "", 0, 0, "FindNode not found");
Else
&qrValue = &RecordNode.GetAttributeValue("asignaFolio ");
Warning MsgGet(0, 0, "asignaFolio." | &qrValue);
End-If;
Else
Warning MsgGet(0, 0, "Error. ParseXmlString");
End-If;
/****************/
XML File:
- <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
- <S:Body>
- <ns4:ResponseGeneraCFDi xmlns="http://www.xxl.com/ns/xsd/bf/rxx/52" xmlns:ns2="http://www.sat.gob.mx/cfd/3" xmlns:ns3="http://www.xx/ns/bf/conector/1&quo t; xmlns:ns4="http://www.xx/ns/xsd/bfxx/xx/32&qu ot; xmlns:ns5="http://www.xxcom/ns/xsd/bf/xxxxx&q uot; xmlns:ns6="http://wwwxx.com/ns/referenceID/v1">
- <ns3:Result version="1">
<ns3:Message message="Proceso realizado con exito." code="0" />
</ns3:Result>
- <ns4:InfoCFDi noCertificadoSAT="20001000000100003992" refId="STORFAC20121022085611" fechaTimbrado="2012-10-22T08:56:45" qr=" "
uuid="a37a7d92-a17e-49f4-8e4d-51c983587acb" version="3.2" tipo="XML" archivo="xxx" sello="B8WjuhYLouSZJ6LU2EjxZ0a4IKyIENZNBx4Lb4 jkcAk6wA+EM477yz91/iDdsON0jm8xibBfom5hvHsH7ZK1ps3NnAXWr1LW 7ctmGsvYKAMvkCx/yOVzJTKFM2hN+OqCTE0WVfgv690vVy2CDQWKlMxbK+3idwG4t OKCMelrN9c=" fecha="2012-10-22T08:56:44" folio="281" serie="IICC">
<InfoEspecial valor="Este documento es una representacin impresa de un CFDI." atributo="leyendaImpresion" />
<InfoEspecial valor="||1.0|a37a7d92-a17e-49f4-8e4d-51c983587acb|2012-10-22T08:56:45|B8WjuhYLouSZJ6LU2EjxZ0a4IKyIENZNBx4Lb4 jkcAk6wA+EM477yz91/iDdsON0jm8xibBfom5hvHsH7ZK1ps3NnAXWr1LW 7ctmGsvYKAMvkCx/yOVzJTKFM2hN+OqCTE0WVfgv690vVy2CDQWKlMxbK+3idwG4t OKCMelrN9c=|20001000000100003992||" atributo="cadenaOriginal" />
<InfoEspecial valor="Doscientos dieciocho mil cuatrocientos setenta y cinco pesos 00/100 M.N." atributo="totalConLetra" />
</ns4:InfoCFDi>
</ns4:ResponseGeneraCFDi>
</S:Body>
</S:Envelope>

TIA
  • 1. Re: FindNode returning Null And XML Not Accepting Special Characters
    Michel Journeyer
    Currently Being Moderated
    First of all you have to supply a value you want to search for and this has to be the complete path to the value. You're saying you already tried that, but can you paste the code which you used for that? I don't see the path mentioned in the code you posted.
    *FindNode*
    Syntax

    FindNode(Path)

    Description

    Use the FindNode method to return a reference to an XmlNode.

    The path is specified as the list of tag names, to the node that you want to find, each separated by a slash (/).

    Parameters

    Path
         
    Specify the tag names up to and including the name of the node that you want returned, starting with a slash and each separated by a slash (/). This is known as the XPath query language.>

    Another option would be this snippet of code:

    &InfoCFDiArray = GetElementsByTagName("ns4:InfoCFDi");
    &InfoCFDiNode = &InfoCFDiArray [1];
    &attValue = &InfoCFDiNode.GetAttributeValue("noCertificadoSAT")

    Warning(&attValue);

    It creates an array of XML Nodes which match the name "ns4:InfoCFDi". Since there's only one in the XML it's safe to assume it will be the one and only node in the array. I've assigned that node to the variable &InfoCFDiNode and use that to retrieve the attribute "noCertificadoSAT" value. The warning message should display the value supplied there.

    Concering the special characters; you will have to change the encoding of the XML. Peoplecode sets this to UTF-8 by default, but doesn't include this in the header. There's a little hack for that somewhere on the web, I'll see if I can find it.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points