FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Help about xml files
Posts: 332
Joined: Thu Nov 17, 2005 09:11 PM
Re: Help about xml files
Posted: Wed Jan 12, 2011 05:05 PM
lailton.webmaster wrote:Try

Code (fw): Select all Collapse
HB_OemToAnsi( UTF8ToStr( cString ) )


Check it:
http://forums.fivetechsupport.com/viewtopic.php?f=6&t=10986&hilit=utf8


Thanks Lailton but doesn't work. I think in give up.
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Help about xml files
Posted: Wed Jan 12, 2011 11:30 PM

Wanderson,

provide a prg that i can compile to test it, and send for my mail.

Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Help about xml files
Posted: Wed Jan 12, 2011 11:56 PM
Wanderson,

I did test with information that you sended before. and work fine to me.
Look:

Demo.prg
Code (fw): Select all Collapse
#include "Fivewin.ch"
Function Main()
 cXML := StrTran( MemoRead( "retorno.xml" ), CRLF )
 xMotivo := GetStringFromXMl('<xMotivo>','</xMotivo>', cXML )
 MsgInfo(xMotivo)
Return Nil
Function GetStringFromXMl( cInicio, cFinal, cString )
Local nInicio:=At( cInicio, cString ) + Len( cInicio )
Local nFinal :=At( cFinal, cString ) - nInicio
Return Alltrim( Substr( cString, nInicio, nFinal ) )


Now the XML
Code (fw): Select all Collapse
<retCancCTe xmlns="http://www.portalfiscal.inf.br/cte" versao="1.03">
<infCanc Id="CTe52110104395298000137570010000000841589634677">
<tpAmb>2</tpAmb>
<cUF>52</cUF>
<verAplic>RS20100226092505</verAplic>
<cStat>218</cStat>
<xMotivo>Rejeição: CT-e ja esta cancelada na base de dados da SEFAZ</xMotivo>
<chCTe>52110104395298000137570010000000841589634677</chCTe>
<dhRecbto>2011-01-12T09:59:15</dhRecbto>
<nProt />
</infCanc>
</retCancCTe>


My result is:


Link to download:
http://www.4shared.com/file/eJgTdIYz/Wanderson.html

The problem is in your request mode. more i need more information for can help you.
:-)
Posts: 332
Joined: Thu Nov 17, 2005 09:11 PM
Re: Help about xml files
Posted: Thu Jan 13, 2011 02:06 AM

Lailton i test your code and runs ok but the problem is not in code but in xml. Try with this xml (this is a sefaz file return).

http://rapidshare.com/files/442284031/Retorno.rar

Thanks.

Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Help about xml files
Posted: Thu Jan 13, 2011 04:25 AM

I´ll see. :o

Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Help about xml files
Posted: Thu Jan 13, 2011 07:25 AM
Wanderson,

Try this way, work fine to me.

http://www.4shared.com/file/R6igNH4s/wanderson-xml.html :-)
Posts: 332
Joined: Thu Nov 17, 2005 09:11 PM
Re: Help about xml files
Posted: Thu Jan 13, 2011 12:22 PM

Thank you Lailton works great.
Just one more observation:

cString := StrTran( MemoRead( "Retorno.xml" ), CRLF )

Some times cString returns empty and Retorno.xml is not empty.
In this case a try again cString := StrTran( MemoRead( "Retorno.xml" ), CRLF ) and returns ok.
It's happen to you?

Thanks.

Posts: 332
Joined: Thu Nov 17, 2005 09:11 PM
Re: Help about xml files
Posted: Thu Jan 13, 2011 12:31 PM

I try this and works well.

For x = 1 to 100

   cXML := StrTran( MemoRead( Arq_Erro ), CRLF )

    If Empty(cXML)
       inkey(0.1)
       loop
            Endif

    cXML := TrataRetornoXml(cXML)
    xMotivo := GetStringFromXMl('&lt;xMotivo&gt;','&lt;/xMotivo&gt;', cXML )

    Exit

Next x

Thanks.

Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Help about xml files
Posted: Thu Jan 13, 2011 01:27 PM
Nice.

Work fine to for me, without it, but you can do it.

Code (fw): Select all Collapse
cXml := ""
Do while Empty( cXml )
   cXML := TrataRetornoXml(StrTran( MemoRead( Arq_Erro ), CRLF ))
   SysRefresh()
EndDo

xMotivo := GetStringFromXMl('<xMotivo>','</xMotivo>', cXML )

:-)

Continue the discussion