Hi Folks!
I have two identical invoices in XML. I parse that files all childs, grandchilds and attributes.
Everything Goes fine, But I notice that I have some invoices different like the others.
For example All my XML have this,and It parse without problem:
<cfdi: Impuestos totalImpuestosTrasladados=“1186.210000”>
<cfdi: Traslados>
<cfdi: Traslado importe=“1186.210000” impuesto=“IVA” tasa=“16.000000”/>
</cfdi:Traslados>
</cfdi:Impuestos>
And the invoices that I’m having Issue have this Structure:
<cfdi: Impuestos>
<cfdi: Traslados>
<cfdi: Traslado importe=“1186.210000” impuesto=“IVA” tasa=“16.000000”/>
</cfdi:Traslados>
</cfdi:Impuestos>
NOTE THAT In this structure I don’t have the attribute “totalImpuestosTrasladados”.
So, when I load one of this XML files, I get this Error: "DB Error: Incorrect decimal value: “for column ‘Impuestos_Impuesto_Trasladado’ at row 1”
I’m Using x.GetAttribute(“totalImpuestosTrasladados”)
where x = XMLNode
What Am I doing wrong?
You need to wrap the getattribute line in a try catch block. Don’t forget to add #pragma breakonexceptions off before the try or the debugger will still stop at the exception - you can just continue of course.
Still I’m getting the same Error
:(. MY Code:
#pragma BreakOnExceptions off
try
dr.column("Impuestos_Impuesto_Trasladado")=objComprobante.objImpuestos.strImpuestos
Catch err As NilObjectException
end try
#Pragma BreakOnExceptions Default
You probably want to catch an xmlexception rather than the NOE.
[quote=198303:@Gerardo García]Still I’m getting the same Error
:(. MY Code:
I also tried to wrap this: strImpuestos = x.GetAttribute(“totalImpuestosTrasladados”)
that is inside of my ClassImpuestos/FromXMLNode.
One question, what NOE is?
Also I’m thinking to evaluate “If TOTALIMPUESTOSTRASLADADOS” Attribute exists then do pass the value to the FromXMLNode module.
Else Msgbox “Doesn’t Exists”
If x.GetAttribute("totalImpuestosTrasladados") then
Msgbox "Existe"
else
Msgbox "No existe"
end if
But I got this error: Type Mismatch error. Expected Boolean, but got String
With NOE Wayne means the NilObjectException
If x.GetAttribute(“totalImpuestosTrasladados”) then …
The if statement expects an boolean, but in your case x.GetAttribute(“totalImpuestosTrasladados”) delivers a string
I think that I solve it, thats that I made:
// Checking for DB errors
If App.mDB.ErrorCode = 1366 Then
ElseIf App.mDB.ErrorCode = 0 Then
ElseIf App.mDB.ErrorCode = 1062 Then
MsgBox "Registro Repetido"
Else
MsgBox("DB Horror: " + App.mDb.ErrorMessage)
return
End If