Alaska Software Inc. - XMLSimpleParser
Username: Password:
AuthorTopic: XMLSimpleParser
Scott KriseXMLSimpleParser
on Wed, 28 Apr 2021 13:31:03 -0400
Hello Everyone,

I'm attempting to use the XMLSimpleParser for the first time and I have a 
question.

So I have an xml file I want to use. I am opening the file using the 
following syntax:

nXMLDoc := XmlDocOpenFile(nXMLFileName)

This step opens the file as expected and returns me the file handle into 
nXMLDoc . Now I am trying to use this file within the XMLSimpleParser, but 
this function wants a textual representation of the file I just opened, not 
the file handle. How can I extract the data from the file so it can be used 
within the parser?

Thanks,

Scott
Osvaldo RamirezRe: XMLSimpleParser
on Wed, 28 Apr 2021 12:58:23 -0600
On 28/04/21 11:31, Scott Krise wrote:
> Hello Everyone,
> 
> I'm attempting to use the XMLSimpleParser for the first time and I have 
> a question.
> 
> So I have an xml file I want to use. I am opening the file using the 
> following syntax:
> 
> nXMLDoc := XmlDocOpenFile(nXMLFileName)
> 
> This step opens the file as expected and returns me the file handle into 
> nXMLDoc . Now I am trying to use this file within the XMLSimpleParser, 
> but this function wants a textual representation of the file I just 
> opened, not the file handle. How can I extract the data from the file so 
> it can be used within the parser?
> 
> Thanks,
> 
> Scott
> 

Scott

I use this code just for READ XML not to take an ACTION over it.

But some times work other not.


cText := memoread( cXMLfile )

 We nee to put this at the begin of the xml text.
cText := '<?xml version="1.0" encoding="UTF-8" ?>'+crlf+cText

   oXML := XmlSimpleParser( cText )

   oComprobante := oXml:Comprobante
   oRelacionados:= oXML:Comprobante:CfdiRelacionados
   oEmisor      := oXml:Comprobante:Emisor
   oReceptor    := oXml:Comprobante:Receptor
   oConceptos   := oXml:Comprobante:Conceptos
   oImpuestos   := oXml:Comprobante:Impuestos
   oComplemento := oXml:Comprobante:Complemento

....

HTH

Osvald Ramirez
Scott KriseRe: XMLSimpleParser
on Wed, 28 Apr 2021 17:06:20 -0400
Thanks Osvaldo, that was very helpful!

"Osvaldo Ramirez" wrote in message 
news:6ebf7b21$aaf4a13$59d63@news.alaska-software.com...

On 28/04/21 11:31, Scott Krise wrote:
> Hello Everyone,
>
> I'm attempting to use the XMLSimpleParser for the first time and I have a 
> question.
>
> So I have an xml file I want to use. I am opening the file using the 
> following syntax:
>
> nXMLDoc := XmlDocOpenFile(nXMLFileName)
>
> This step opens the file as expected and returns me the file handle into 
> nXMLDoc . Now I am trying to use this file within the XMLSimpleParser, but 
> this function wants a textual representation of the file I just opened, 
> not the file handle. How can I extract the data from the file so it can be 
> used within the parser?
>
> Thanks,
>
> Scott
>

Scott

I use this code just for READ XML not to take an ACTION over it.

But some times work other not.


cText := memoread( cXMLfile )

 We nee to put this at the begin of the xml text.
cText := '<?xml version="1.0" encoding="UTF-8" ?>'+crlf+cText

   oXML := XmlSimpleParser( cText )

   oComprobante := oXml:Comprobante
   oRelacionados:= oXML:Comprobante:CfdiRelacionados
   oEmisor      := oXml:Comprobante:Emisor
   oReceptor    := oXml:Comprobante:Receptor
   oConceptos   := oXml:Comprobante:Conceptos
   oImpuestos   := oXml:Comprobante:Impuestos
   oComplemento := oXml:Comprobante:Complemento

....

HTH

Osvald Ramirez
Osvaldo RamirezRe: XMLSimpleParser
on Thu, 29 Apr 2021 10:41:58 -0600
On 28/04/21 15:06, Scott Krise wrote:
> Thanks Osvaldo, that was very helpful!
> 
> "Osvaldo Ramirez" wrote in message 
> news:6ebf7b21$aaf4a13$59d63@news.alaska-software.com...
> 
> On 28/04/21 11:31, Scott Krise wrote:
>> Hello Everyone,
>>
>> I'm attempting to use the XMLSimpleParser for the first time and I 
>> have a question.
>>
>> So I have an xml file I want to use. I am opening the file using the 
>> following syntax:
>>
>> nXMLDoc := XmlDocOpenFile(nXMLFileName)
>>
>> This step opens the file as expected and returns me the file handle 
>> into nXMLDoc . Now I am trying to use this file within the 
>> XMLSimpleParser, but this function wants a textual representation of 
>> the file I just opened, not the file handle. How can I extract the 
>> data from the file so it can be used within the parser?
>>
>> Thanks,
>>
>> Scott
>>
> 
> Scott
> 
> I use this code just for READ XML not to take an ACTION over it.
> 
> But some times work other not.
> 
> 
> cText := memoread( cXMLfile )
> 
>  We nee to put this at the begin of the xml text.
> cText := '<?xml version="1.0" encoding="UTF-8" ?>'+crlf+cText
> 
>   oXML := XmlSimpleParser( cText )
> 
>   oComprobante := oXml:Comprobante
>   oRelacionados:= oXML:Comprobante:CfdiRelacionados
>   oEmisor      := oXml:Comprobante:Emisor
>   oReceptor    := oXml:Comprobante:Receptor
>   oConceptos   := oXml:Comprobante:Conceptos
>   oImpuestos   := oXml:Comprobante:Impuestos
>   oComplemento := oXml:Comprobante:Complemento
> 
> ....
> 
> HTH
> 
> Osvald Ramirez

Scott

More info.

Nodes with one child VS nodes with more the one child


XML piece of code XML to see :

***************

<cfdi:Conceptos>

	<cfdi:Concepto ClaveProdServ="51161800" 
NoIdentificacion="7501001147594" Cantidad="1" ClaveUnidad="H87" 
Unidad="PIEZA" Descripcion="VICK PASTILLAS MENTA EUCALIPTO EUCALIPTO 
ALCANFOR TIMOL MENTOL 20 CAJ" ValorUnitario="14.77" Importe="14.77">
		<cfdi:Impuestos>
			<cfdi:Traslados>
				<cfdi:Traslado Base="14.77" Impuesto="003" 	TipoFactor="Tasa" 
TasaOCuota="0.080000" Importe="1.18" />
<cfdi:Traslado Base="14.77" Impuesto="002" TipoFactor="Tasa" 
TasaOCuota="0.000000" Importe="0.00" />
			</cfdi:Traslados>
		</cfdi:Impuestos>

	</cfdi:Concepto>

	<cfdi:Concepto ClaveProdServ="53131622" 
NoIdentificacion="7501080950139" Cantidad="1" ClaveUnidad="H87" 
Unidad="PIEZA" Descripcion="PRESERVATIVO TROJAN CLASICO PRESERVATIVOS 3 
BLI" ValorUnitario="29.37" Importe="29.37">

		<cfdi:Impuestos>
			<cfdi:Traslados>
				<cfdi:Traslado Base="29.37" Impuesto="002" TipoFactor="Tasa" 
TasaOCuota="0.160000" Importe="4.70" />
			</cfdi:Traslados>
		</cfdi:Impuestos>

	</cfdi:Concepto>


**************

The node cfdi:Conceptos has two nodes ( Concepto )

  oConceptos   := oXml:Comprobante:Conceptos   get the note as object

So :

?  valtype( oConceptos:concepto )  this is array of two elements

But if the there was only one node, then the return of valtype() is an 
object and not an array of objects.


Regards
Osvaldo Ramirez