Help about xml files

Re: Help about xml files

Postby Wanderson » Wed Jan 12, 2011 5:05 pm

lailton.webmaster wrote:Try

Code: Select all  Expand view
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.
Wanderson
 
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Re: Help about xml files

Postby lailton.webmaster » Wed Jan 12, 2011 11:30 pm

Wanderson,

provide a prg that i can compile to test it, and send for my mail.
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Help about xml files

Postby lailton.webmaster » 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: Select all  Expand view

#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: Select all  Expand view
<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:
Image

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.
:)
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Help about xml files

Postby Wanderson » Thu Jan 13, 2011 2: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.
Wanderson
 
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Re: Help about xml files

Postby lailton.webmaster » Thu Jan 13, 2011 4:25 am

I´ll see. :o
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Help about xml files

Postby lailton.webmaster » Thu Jan 13, 2011 7:25 am

Wanderson,

Try this way, work fine to me.

http://www.4shared.com/file/R6igNH4s/wanderson-xml.html :wink:
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Help about xml files

Postby Wanderson » 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.
Wanderson
 
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Re: Help about xml files

Postby Wanderson » 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('<xMotivo>','</xMotivo>', cXML )

Exit

Next x

Thanks.
Wanderson
 
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Re: Help about xml files

Postby lailton.webmaster » Thu Jan 13, 2011 1:27 pm

Nice.

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

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

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

:D
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 70 guests