FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour XML viewer
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: XML viewer
Posted: Sun Mar 03, 2013 08:28 AM
Antonio Linares wrote:Marc,

Could you post your XML file here ? Or send it to me by email, thanks :-)


Just sended by email..
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: XML viewer
Posted: Sun Mar 03, 2013 10:39 AM
Marc,

Your XML has two incorrect characters at the beginning, not visibles, but make the XML functions to fail:

Please edit your XML file in hex mode (or binary mode) and remove the leading FF FE chars:

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: XML viewer
Posted: Sun Mar 03, 2013 10:52 AM

Antonio,

Thank you.
After deleting the FF and FE, I had the same problem.
Then I opened it with notepath, and saved it as an ANSI-file, and it works :D
This action also removed also the FF and FE!!

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: XML viewer
Posted: Sun Mar 03, 2013 11:00 AM

Very good :-)

Yes, I just noticed too, that there were zeroes after each char. I removed them this way:

MemoWrit( "test.xml", StrTran( SubStr( MemoRead( "test.xml" ), 3 ), Chr( 0 ), "" ) )

anyhow your notepad solution is even simpler :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: XML viewer
Posted: Sun Mar 03, 2013 11:05 AM
Antonio Linares wrote:Very good :-)

Yes, I just noticed too, that there were zeroes after each char. I removed them this way:

MemoWrit( "test.xml", StrTran( SubStr( MemoRead( "test.xml" ), 3 ), Chr( 0 ), "" ) )

anyhow your notepad solution is even simpler :-)


Antonio,

Since I want to import more than 8000 XML-files in my program, I think it's better and faster to use
Code (fw): Select all Collapse
MemoWrit( "test.xml", StrTran( SubStr( MemoRead( "test.xml" ), 3 ), Chr( 0 ), "" ) )
than opening each file and save it again as ansi :-)

I will search a way to convert if from UNICODE to ANSI in my code.
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Re: XML viewer
Posted: Wed Mar 06, 2013 08:36 PM

Hi Antonio,

I am using your XML viewer to load XML data to DBF (DBFCDX). However, when I load the XML data to the DBF it is corrupting the DBF. What could be causing that?

I use a back up of the structure and rename the corrupted DBF then run a DBF fix program that performs the following

function __dbFix( cSource, cDestination )
cDb = cDestination
DO WHILE (.T.)
USE (cDb) NEW EXCLUSIVE
IF NETERR()
MsgAlert( 'Unable to open ' + UPPER( cDb ) + ', process aborted...' )
lFail := .T.
ENDIF
EXIT
ENDDO
IF lFail
RETURN (.F.)
ENDIF
APPEND FROM (cSource)
nTotRec := (cDb)->( reccount() )
DbCloseAll()

*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: XML viewer
Posted: Thu Mar 07, 2013 08:35 AM

Darrell,

Please post the code that you use to port your data from the XML to the DBF

Probably there are invalid chars i.e. chr( 255 ) or similars in the data read from the XML

Is it the same XML file that you emailed me ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Re: XML viewer
Posted: Thu Mar 07, 2013 08:47 AM

Hi Antonio,

Here is code, I am e-mailing XML to you

include "FiveWin.ch"

//----------------------------------------------------------------------------//
function _PashaIn( oSay1, oSay2 )

local lFail := .F. , ;
cSkipped := '' , ;
cSource := "C:\Winapps\vessel\xml\inbox\" , ;
cHistory := "C:\Winapps\vessel\xml\inbox\history\" , ;
nXmlCnt := 0 , ;
lXmlOk := .F.

IF Plive
cSource := "C:\Winapps\websvc\inbound\"
cHistory := "C:\Winapps\websvc\inbound\history\"
ENDIF

// Open...
IF ! _db( Pdd, "bkgreq" )
RETURN (.F.)
ENDIF
IF ! _db( Pdd, "bkgdet" )
RETURN (.F.)
ENDIF

// Init...
aXmlFile := Directory( cSource + "*.XML" )

FOR nXml1=1 TO LEN(aXmlFile)

  // Message...
  oSay1:SetText( LTRIM( STR( ROUND( (nXml1/LEN(aXmlFile))*100, 0), 3) ) + '% . . . Parsing XML ' + cSource + aXmlFile[nXml1,1] )
  SysRefresh()

  // Process...
  lXmlOk := _XmlRead2( cSource + aXmlFile[nXml1,1], @oSay1, @oSay2 )

  // Copy...
  IF lXmlOk
     cC1 := cSource  + aXmlFile[nXml1,1]
     cC2 := cHistory + aXmlFile[nXml1,1]
     COPY FILE (cC1) TO (cC2)

     // Delete...
     IF FILE( cC2 )
        FERASE( cC1 )

        // Counter...
        nXmlCnt++
     ENDIF
  ENDIF

NEXT nXml1
DbCloseAll()

// Message...
oSay1:SetText( 'XML Processed = ' + LTRIM( TRANSF( nXmlCnt, "999,999" ) ) )
oSay2:SetText( 'Process Complete...' )
SysRefresh()

RETURN nil

//-----------------------------------------------------------------------------
function _XmlRead2( cFileName, oSay1, oSay2 )

LOCAL hFile , ;
oXmlDoc , ;
oXmlIter , ;
oTagActual

// Init...
cSenderDocumentId := ""
cDocTransDate := ""
cDetailCount := ""
cSenderName := ""
cDetailId := ""
cDetailAction := ""
cPashaShipmentId := ""
cShipmentNumber := ""
cDetailCarrier := ""
cDetailFirst := ""
cDetailLast := ""
cDetailPhone := ""
cDetailEmail := ""
cDetailWtCode := ""
cDetailVolCode := ""
cDetailVolume := ""
cDetailGrossWt := ""
cDetailTareWt := ""
cDetailNetWt := ""
cDetailPieces := ""
cDetailTotalPcs := ""
cDetailBkgDate := ""
cDetailDelvDate := ""
cDetailTranspId := ""
cDetailTransitId := ""
cDetailCtnrType := ""
cDetailContract := ""
cDetailClauses := ""
cDetailMoveType := ""
cDetailDesc := ""
cDetailCharges := ""
cDetailDocType := ""
cDetailDocRate := ""
cDetailPackage := ""
cDetailFrtPay := ""
cDetailPlaceRel := ""
cDetailItemCode := ""
cDetailPCtnrId := ""
cDetailContainer := ""
cDetailSeal := ""
cDetailSize := ""
cPashaGbl := ""
cPashaBkgNo := ""
cPashaExtNo := ""
cShipName := ""
cShipAdd1 := ""
cShipAdd2 := ""
cShipCity := ""
cShipState := ""
cShipZip := ""
cShipCountry := ""
cConsName := ""
cConsAdd1 := ""
cConsAdd2 := ""
cConsCity := ""
cConsState := ""
cConsZip := ""
cConsCountry := ""
cNotiName := ""
cNotiAdd1 := ""
cNotiAdd2 := ""
cNotiCity := ""
cNotiState := ""
cNotiZip := ""
cNotiCountry := ""
cForwName := ""
cForwAdd1 := ""
cForwAdd2 := ""
cForwCity := ""
cForwState := ""
cForwZip := ""
cForwCountry := ""
cEtd1 := ""
cEtdTime1 := ""
cEtd2 := ""
cEtdTime2 := ""
cEta := ""
cEtaTime := ""
cSteamshipLine := ""
cVessel := ""
cVoyage := ""
cEtdTime := ""
cPortOfDeparture := ""
cPortOfArrival := ""
cDetailDestArea := ""
cDetailDestBase := ""
Mcustid := "PASHAINTL"
Magentid := "PASHAUSCZL"
nDetailId := 0
cXmlOutBox := "c:\winapps\vessel\xml\outbox\"
cXmlOutHist := "c:\winapps\vessel\xml\outbox\history\"
cResponseType := "A"
nXml := 1
lFail := .F.
dDocRecvDate := DATE()
cDocRecvTime := TIME()
aXml997 := {}
nBkgRec := 0
nDetRec := 0
cSerial := ""
cSiId := ""
nDetCnt := 0
cResponseMessage := ""
cName := ""
cType := ""
cAddress1 := ""
cAddress2 := ""
cCity := ""
cState := ""
cZip := ""
cCountry := ""
lTransitXmlKey := .F.

If ! FILE(cFileName)
RETURN (.F.)
Endif

IF Plive
cXmlOutBox := "C:\winapps\websvc\outbound\"
cXmlOutHist := "C:\winapps\websvc\outbound\history\"
ENDIF

// Open...
hFile := FOPEN( cFileName )

// Init...
oXmlDoc := TXmlDocument():New( hFile )
oXmlIter := TXmlIterator():New( oXmlDoc:oRoot )

WHILE .T.
oTagActual = oXmlIter:Next()
If oTagActual != nil
_XmlParse( oTagActual:cName, oTagActual:cData )
HEval( oTagActual:aAttributes, { | cKey, cValue | _XmlParse( cKey, cValue, oTagActual:cName ) } )
ELSE
EXIT
ENDIF
END

FClose( hFile )

// Process 997...
IF (nBkgRec>0)
_Xml997( nBkgRec, @oSay1, @oSay2, cResponseType )
ENDIF

RETURN (.T.)

//-----------------------------------------------------------------------------
FUNCTION _XmlParse( cKeyName, cKeyValue, cTagName )

local cKeyName1 := "" , ;
cKeyValue1 := "" , ;
cTagName1 := ""

IF PCOUNT()<3
cTagName := ""
ENDIF
IF cKeyName=nil
cKeyName := ""
ENDIF
IF cKeyValue=nil
cKeyValue := ""
ENDIF

// Init...
cTagName1 := UPPER( cTagName )
cKeyName1 := UPPER( cKeyName )
cKeyValue1 := UPPER( cKeyValue )

DO CASE
CASE cKeyName1=="SENDERDOCUMENTID"
cSenderDocumentId := cKeyValue1

 CASE cKeyName1==&quot;DOCUMENTTRANSMISSIONDATE&quot;
      cDocTransDate     := cKeyValue1

 CASE cKeyName1==&quot;DETAILCOUNT&quot;
      cDetailCount      := cKeyValue1

 CASE cTagName1==&quot;SENDER&quot; .AND. cKeyName1==&quot;FULLNAME&quot;
      cSenderName2      := cKeyValue1

 CASE cKeyName1==&quot;DETAIL&quot;         // Process Here...
      IF ! EMPTY( ALLTRIM(cPashaBkgNo) )

         // Open...
         _db( Pdd, &quot;bkgreq&quot; )
         _db( Pdd, &quot;bkgdet&quot; )

         // Init...
         nBkgRec := 0
         nDetRec := 0
         cSerial := &quot;&quot;
         cSiId   := &quot;&quot;
         nDetCnt := 0

         SELECT bkgreq
         GO TOP
         DO WHILE ! EOF()
            IF ALLTRIM(bkgreq-&gt;pbno)==ALLTRIM(cPashaBkgNo)
               nBkgRec := bkgreq-&gt;( recno() )
               cSiId   := ALLTRIM( bkgreq-&gt;siid )
               cSerial := ALLTRIM( bkgreq-&gt;serial )
               EXIT
            ENDIF
            SKIP
         ENDDO

         IF ! EMPTY( cSerial )
            SELECT bkgdet
            GO TOP
            DO WHILE ! EOF()
               IF ALLTRIM( bkgdet-&gt;serial )==cSerial
                  nDetRec   := bkgdet-&gt;( recno() )
                  FOR nX1=1 TO 15
                      cTmp := RIGHT( &quot;00&quot; + LTRIM(STR(nX1,9)), 2)
                      IF ( ALLTRIM( bkgdet-&gt;pashacid&amp;cTmp )== cDetailPCtnrId )
                         nDetailId := nX1
                         EXIT
                      ENDIF
                  NEXT nX1
                  IF (nDetRec&gt;0)
                     EXIT
                  ENDIF
               ENDIF
               SKIP
            ENDDO
         ENDIF

         // Get available record...
         IF (nDetRec&gt;0) .AND. (nDetailId&lt;1)
            SELECT bkgdet
            GO nDetRec
            FOR nX1=1 TO 15
                cTmp := RIGHT( &quot;00&quot; + LTRIM(STR(nX1,9)), 2)
                IF EMPTY( ALLTRIM( bkgdet-&gt;pashacid&amp;cTmp ) )
                   nDetailId := nX1
                   EXIT
                ENDIF
            NEXT nX1
         ENDIF
         IF (nDetRec=0)
            nDetailId := 1
         ENDIF

         // Init...
         IF EMPTY( cSerial )
            cSerial := _AsnNumber( Mcustid, &quot;SERIAL&quot; )
         ENDIF
         IF EMPTY( cSiId )
            cSiid := _AsnNumber( Mcustid, &quot;SHIPINST&quot; )
         ENDIF

         // Update Header...
         SELECT bkgreq
         IF (nBkgRec&lt;1)
            APPEND BLANK
            bkgreq-&gt;customer          := Mcustid
            bkgreq-&gt;agentid           := Magentid
            bkgreq-&gt;serial            := cSerial
            bkgreq-&gt;siid              := cSiId
            bkgreq-&gt;pbno              := cPashaBkgNo
            bkgreq-&gt;sireqtype         := &quot;9&quot;
            bkgreq-&gt;sireqdate         := DATE()
            bkgreq-&gt;sireqtime         := TIME()
            bkgreq-&gt;adduser           := &quot;PASHA WEB SERVICES&quot;
            bkgreq-&gt;adddate           := DATE()
            bkgreq-&gt;addtime           := TIME()
          ELSE
            GO nBkgRec
         ENDIF
         DO WHILE (.T.)
            IF bkgreq-&gt;( rlock() )
               bkgreq-&gt;service        := _Clean( cDetailMoveType )
               bkgreq-&gt;ctref          := cDetailContract
               bkgreq-&gt;scac           := _Map2Pasha( &quot;PASHACARRIER&quot;, _Clean( cSteamshipLine ) )
               bkgreq-&gt;vessel         := _Clean( cVessel )
               bkgreq-&gt;voyage         := _Clean( cVoyage )
               bkgreq-&gt;portload       := _Map2Pasha( &quot;PASHAPORT&quot; , _Clean( cPortOfDeparture ) )
               bkgreq-&gt;portload2      := _Map2Pasha( &quot;PASHAPORT2&quot;, _Clean( cPortOfDeparture ) )
               bkgreq-&gt;portdisc       := _Map2Pasha( &quot;PASHAPORT&quot; , _Clean( cPortOfArrival ) )
               bkgreq-&gt;portdisc2      := _Map2Pasha( &quot;PASHAPORT2&quot;, _Clean( cPortOfArrival ) )
               bkgreq-&gt;etd            := CTOD( SUBSTR( cEtd1, 6, 2 ) + &quot;/&quot; + SUBSTR( cEtd1, 9, 2 ) + &quot;/&quot; + LEFT( cEtd1, 4 ) )
               bkgreq-&gt;eta            := CTOD( SUBSTR( cEta, 6, 2 )  + &quot;/&quot; + SUBSTR( cEta, 9, 2 )  + &quot;/&quot; + LEFT( cEta, 4 ) )
               bkgreq-&gt;shipname       := _Clean( cShipname )
               bkgreq-&gt;shipadd1       := _Clean( cShipadd1 )
               bkgreq-&gt;shipadd2       := _Clean( cShipadd2 )
               bkgreq-&gt;shipcity       := _Clean( cShipcity )
               bkgreq-&gt;shipst         := _Clean( cShipstate )
               bkgreq-&gt;shipzip        := _Clean( cShipZip )
               bkgreq-&gt;shipiso        := _Clean( cShipCountry )
               bkgreq-&gt;consname       := _Clean( cConsname )
               bkgreq-&gt;consadd1       := _Clean( cConsadd1 )
               bkgreq-&gt;consadd2       := _Clean( cConsadd2 )
               bkgreq-&gt;conscity       := _Clean( cConscity )
               bkgreq-&gt;consst         := _Clean( cConsstate )
               bkgreq-&gt;conszip        := _Clean( cConsZip )
               bkgreq-&gt;consiso        := _Clean( cConsCountry )
               bkgreq-&gt;notiname       := _Clean( cNotiname )
               bkgreq-&gt;notiadd1       := _Clean( cNotiadd1 )
               bkgreq-&gt;notiadd2       := _Clean( cNotiadd2 )
               bkgreq-&gt;noticity       := _Clean( cNoticity )
               bkgreq-&gt;notist         := _Clean( cNotistate )
               bkgreq-&gt;notizip        := _Clean( cNotiZip )
               bkgreq-&gt;notiiso        := _Clean( cNotiCountry )
               bkgreq-&gt;forwname       := _Clean( cForwname )
               bkgreq-&gt;forwadd1       := _Clean( cForwadd1 )
               bkgreq-&gt;forwadd2       := _Clean( cForwadd2 )
               bkgreq-&gt;forwcity       := _Clean( cForwcity )
               bkgreq-&gt;forwst         := _Clean( cForwstate )
               bkgreq-&gt;forwzip        := _Clean( cForwZip )
               bkgreq-&gt;forwiso        := _Clean( cForwCountry )
               bkgreq-&gt;charges        := _Map2Pasha( &quot;PASHACHARGES&quot;, _Clean( cDetailCharges ) )
               bkgreq-&gt;ctnr01qty      := 1
               bkgreq-&gt;ctnr01type     := _Map2Pasha( &quot;PASHACONTAINER&quot;, _Clean( cDetailCtnrType ) )
               bkgreq-&gt;lastuser       := &quot;PASHA WEB SERVICES&quot;
               bkgreq-&gt;lastdate       := DATE()
               bkgreq-&gt;lasttime       := TIME()
               bkgreq-&gt;pdocid         := _Clean( cSenderDocumentId )
               bkgreq-&gt;pdetcnt        := _Clean( cDetailCount )
               bkgreq-&gt;psender        := _Clean( cSenderName )
               bkgreq-&gt;ptransdate     := _Clean( cDocTransDate )
               bkgreq-&gt;pextref        := _Clean( cPashaExtNo )
               bkgreq-&gt;( dbunlock() )
               EXIT
            ENDIF
         ENDDO

         // Update Detail...
         SELECT bkgdet
         IF (nDetRec&lt;1)
            APPEND BLANK
            bkgdet-&gt;customer          := Mcustid
            bkgdet-&gt;serial            := cSerial
            bkgdet-&gt;siid              := cSiId
          ELSE
            GO nDetRec
         ENDIF
         DO WHILE (.T.)
            IF bkgdet-&gt;( rlock() )
               cTmp                   := RIGHT( &quot;00&quot; + LTRIM(STR(nDetailId,9)), 2)
               bkgdet-&gt;pkgtype        := _Clean( cDetailPackage )
               bkgdet-&gt;desc           := _Clean( cDetailDesc )
               bkgdet-&gt;hscode         := _Clean( cDetailItemCode )
               bkgdet-&gt;gwtcode        := _Clean( cDetailWtCode )
               bkgdet-&gt;nwtcode        := _Clean( cDetailWtCode )
               bkgdet-&gt;volcode        := _Clean( cDetailVolCode )
               bkgdet-&gt;smfirst&amp;cTmp   := _Clean( cDetailFirst )
               bkgdet-&gt;smlast&amp;cTmp    := _Clean( cDetailLast )
               bkgdet-&gt;scac&amp;cTmp      := _Clean( cDetailCarrier )
               bkgdet-&gt;area&amp;cTmp      := _Clean( cDetailDestArea )
               bkgdet-&gt;gbloc&amp;cTmp     := _Clean( cDetailDestBase )
               bkgdet-&gt;gbl&amp;cTmp       := _Clean( cShipmentNumber )
               bkgdet-&gt;qty&amp;cTmp       := _Clean( cDetailPieces )
               bkgdet-&gt;qty&amp;cTmp.t     := _Clean( cDetailTotalPcs )
               bkgdet-&gt;grs&amp;cTmp       := VAL( _Clean( cDetailGrossWt ) )
               bkgdet-&gt;net&amp;cTmp       := VAL( _Clean( cDetailNetWt ) )
               bkgdet-&gt;vol&amp;cTmp       := VAL( _Clean( cDetailVolume ) )
               bkgdet-&gt;ctnr&amp;cTmp      := _Clean( cDetailContainer )
               bkgdet-&gt;seal&amp;cTmp      := _Clean( cDetailSeal )
               bkgdet-&gt;size&amp;cTmp      := _Map2Pasha( &quot;PASHACONTAINER&quot;, _Clean( cDetailCtnrType ) )
               bkgdet-&gt;pasha&amp;cTmp     := _Clean( cPashaShipmentId )
               bkgdet-&gt;ph&amp;cTmp        := _Clean( cDetailPhone )
               bkgdet-&gt;transp&amp;cTmp    := _Clean( cDetailTranspId )
               bkgdet-&gt;transit&amp;cTmp   := _Clean( cDetailTransitId )
               bkgdet-&gt;pashacid&amp;cTmp  := _Clean( cDetailPCtnrId )
               bkgdet-&gt;( dbunlock() )
               EXIT
            ENDIF
         ENDDO

         // Close...
         _dbClose( &quot;bkgreq&quot; )
         _dbClose( &quot;bkgdet&quot; )

      ENDIF

      // Init...
      cDetailId         := &quot;&quot;
      cDetailAction     := &quot;&quot;
      cPashaShipmentId  := &quot;&quot;
      cShipmentNumber   := &quot;&quot;
      cDetailCarrier    := &quot;&quot;
      cDetailFirst      := &quot;&quot;
      cDetailLast       := &quot;&quot;
      cDetailPhone      := &quot;&quot;
      cDetailEmail      := &quot;&quot;
      cDetailWtCode     := &quot;&quot;
      cDetailVolCode    := &quot;&quot;
      cDetailVolume     := &quot;&quot;
      cDetailGrossWt    := &quot;&quot;
      cDetailTareWt     := &quot;&quot;
      cDetailNetWt      := &quot;&quot;
      cDetailPieces     := &quot;&quot;
      cDetailTotalPcs   := &quot;&quot;
      cDetailBkgDate    := &quot;&quot;
      cDetailDelvDate   := &quot;&quot;
      cDetailTranspId   := &quot;&quot;
      cDetailTransitId  := &quot;&quot;
      cDetailCtnrType   := &quot;&quot;
      cDetailContract   := &quot;&quot;
      cDetailClauses    := &quot;&quot;
      cDetailMoveType   := &quot;&quot;
      cDetailDesc       := &quot;&quot;
      cDetailCharges    := &quot;&quot;
      cDetailDocType    := &quot;&quot;
      cDetailDocRate    := &quot;&quot;
      cDetailPackage    := &quot;&quot;
      cDetailFrtPay     := &quot;&quot;
      cDetailPlaceRel   := &quot;&quot;
      cDetailItemCode   := &quot;&quot;
      cDetailPCtnrId    := &quot;&quot;
      cDetailContainer  := &quot;&quot;
      cDetailSeal       := &quot;&quot;
      cDetailSize       := &quot;&quot;
      cPashaGbl         := &quot;&quot;
      cPashaBkgNo       := &quot;&quot;
      cPashaExtNo       := &quot;&quot;
      cShipName         := &quot;&quot;
      cShipAdd1         := &quot;&quot;
      cShipAdd2         := &quot;&quot;
      cShipCity         := &quot;&quot;
      cShipState        := &quot;&quot;
      cShipZip          := &quot;&quot;
      cShipCountry      := &quot;&quot;
      cConsName         := &quot;&quot;
      cConsAdd1         := &quot;&quot;
      cConsAdd2         := &quot;&quot;
      cConsCity         := &quot;&quot;
      cConsState        := &quot;&quot;
      cConsZip          := &quot;&quot;
      cConsCountry      := &quot;&quot;
      cNotiName         := &quot;&quot;
      cNotiAdd1         := &quot;&quot;
      cNotiAdd2         := &quot;&quot;
      cNotiCity         := &quot;&quot;
      cNotiState        := &quot;&quot;
      cNotiZip          := &quot;&quot;
      cNotiCountry      := &quot;&quot;
      cForwName         := &quot;&quot;
      cForwAdd1         := &quot;&quot;
      cForwAdd2         := &quot;&quot;
      cForwCity         := &quot;&quot;
      cForwState        := &quot;&quot;
      cForwZip          := &quot;&quot;
      cForwCountry      := &quot;&quot;
      cEtd1             := &quot;&quot;
      cEtdTime1         := &quot;&quot;
      cEtd2             := &quot;&quot;
      cEtdTime2         := &quot;&quot;
      cEta              := &quot;&quot;
      cEtaTime          := &quot;&quot;
      cSteamshipLine    := &quot;&quot;
      cVessel           := &quot;&quot;
      cVoyage           := &quot;&quot;
      cEtdTime          := &quot;&quot;
      cPortOfDeparture  := &quot;&quot;
      cPortOfArrival    := &quot;&quot;
      cDetailDestArea   := &quot;&quot;
      cDetailDestBase   := &quot;&quot;
      lTransit          := .F.
      lTransportItem    := .F.
      lDetail           := .F.
      nDetailId         := 0
      cName             := &quot;&quot;
      cType             := &quot;&quot;
      cAddress1         := &quot;&quot;
      cAddress2         := &quot;&quot;
      cCity             := &quot;&quot;
      cState            := &quot;&quot;
      cZip              := &quot;&quot;
      cCountry          := &quot;&quot;
      lTransitXmlKey    := .F.


 CASE cTagName1==&quot;DETAIL&quot; .AND. cKeyName1==&quot;ACTION&quot;
      cDetailAction     := cKeyValue1

 CASE cTagName1==&quot;DETAIL&quot; .AND. cKeyName1==&quot;ID&quot;
      cDetailId         := cKeyValue1

 CASE cTagName1==&quot;IDENTIFIERS&quot; .AND. cKeyName1==&quot;CARRIERSCAC&quot;
      cDetailCarrier    := cKeyValue1
 CASE cTagName1==&quot;IDENTIFIERS&quot; .AND. cKeyName1==&quot;SHIPMENTNUMBER&quot;
      cShipmentNumber   := cKeyValue1
 CASE cTagName1==&quot;IDENTIFIERS&quot; .AND. cKeyName1==&quot;PASHASHIPMENTRECORDID&quot;
      cPashaShipmentId  := cKeyValue1
 CASE cTagName1==&quot;IDENTIFIERS&quot; .AND. cKeyName1==&quot;PASHACONTAINERRECORDID&quot;
      cDetailPCtnrId    := cKeyValue1
 CASE cTagName1==&quot;IDENTIFIERS&quot; .AND. cKeyName1==&quot;TRANSPORTITEMNUMBER&quot;
      cDetailContainer  := cKeyValue1
 CASE cTagName1==&quot;IDENTIFIERS&quot; .AND. cKeyName1==&quot;SEALNUMBER&quot;
      cDetailSeal       := cKeyValue1
 CASE cTagName1==&quot;IDENTIFIERS&quot; .AND. cKeyName1==&quot;BOOKINGNUMBER&quot;
      IF lTransitXmlKey
         cPashaBkgNo       := cKeyValue1
         lTransitXmlKey    := .F.
      ENDIF
 CASE cTagName1==&quot;IDENTIFIERS&quot; .AND. cKeyName1==&quot;EXTERNALREFERENCEVALUE&quot;
      cPashaExtNo       := cKeyValue1

 CASE cTagName1==&quot;SHIPPERDETAILS&quot; .AND. cKeyName1==&quot;CONTACTGIVENNAME&quot;
      cDetailFirst      := cKeyValue1
 CASE cTagName1==&quot;SHIPPERDETAILS&quot; .AND. cKeyName1==&quot;CONTACTFAMILYNAME&quot;
      cDetailLast       := cKeyValue1
 CASE cTagName1==&quot;SHIPPERDETAILS&quot; .AND. cKeyName1==&quot;PHONE1&quot;
      cDetailPhone      := cKeyValue1
 CASE cTagName1==&quot;SHIPPERDETAILS&quot; .AND. cKeyName1==&quot;EMAIL1&quot;
      cDetailEmail      := cKeyValue1

 CASE cTagName1==&quot;ORIGIN&quot; .AND. cKeyName1==&quot;PORTOFDEPARTURE&quot;
      cPortOfDeparture  := cKeyValue1

 CASE cTagName1==&quot;DESTINATION&quot; .AND. cKeyName1==&quot;PORTOFARRIVAL&quot;
      cPortOfArrival    := cKeyValue1
 CASE cTagName1==&quot;DESTINATION&quot; .AND. cKeyName1==&quot;DESTINATIONAREA&quot;
      cDetailDestArea   := cKeyValue1
 CASE cTagName1==&quot;DESTINATION&quot; .AND. cKeyName1==&quot;DESTINATIONBASEABBREVIATION&quot;
      cDetailDestBase   := cKeyValue1

 CASE cTagName1==&quot;PHYSICAL&quot; .AND. cKeyName1==&quot;WEIGHTUNITS&quot;
      cDetailWtCode     := cKeyValue1
 CASE cTagName1==&quot;PHYSICAL&quot; .AND. cKeyName1==&quot;VOLUMEUNITS&quot;
      cDetailVolCode    := cKeyValue1
 CASE cTagName1==&quot;PHYSICAL&quot; .AND. cKeyName1==&quot;CUBEVOLUME&quot;
      cDetailVolume     := cKeyValue1
 CASE cTagName1==&quot;PHYSICAL&quot; .AND. cKeyName1==&quot;GROSSWEIGHT&quot;
      cDetailGrossWt    := cKeyValue1
 CASE cTagName1==&quot;PHYSICAL&quot; .AND. cKeyName1==&quot;TAREWEIGHT&quot;
      cDetailTareWt     := cKeyValue1
 CASE cTagName1==&quot;PHYSICAL&quot; .AND. cKeyName1==&quot;NETWEIGHT&quot;
      cDetailNetWt      := cKeyValue1
 CASE cTagName1==&quot;PHYSICAL&quot; .AND. cKeyName1==&quot;PIECECOUNT&quot;
      cDetailPieces     := cKeyValue1

 CASE cTagName1==&quot;DATES&quot; .AND. cKeyName1==&quot;BOOKINGDATE&quot;
      cDetailBkgDate    := cKeyValue1
 CASE cTagName1==&quot;DATES&quot; .AND. cKeyName1==&quot;REQUESTEDDELIVERYDATE&quot;
      cDetailDelvDate   := cKeyValue1
 CASE cTagName1==&quot;DATES&quot; .AND. cKeyName1==&quot;ESTIMATEDTIMEOFDEPARTUREDATE&quot;
      cEtd1             := cKeyValue1
 CASE cTagName1==&quot;DATES&quot; .AND. cKeyName1==&quot;ACTUALTIMEOFDEPARTUREDATE&quot;
      cEtd2             := cKeyValue1
 CASE cTagName1==&quot;DATES&quot; .AND. cKeyName1==&quot;ESTIMATEDTIMEOFARRIVALDATE&quot;
      cEta              := cKeyValue1

 CASE cTagName1==&quot;FACTS&quot; .AND. cKeyName1==&quot;CONTAINERTYPE&quot;
      cDetailCtnrType   := cKeyValue1
 CASE cTagName1==&quot;FACTS&quot; .AND. cKeyName1==&quot;CONTRACTNUMBER&quot;
      cDetailContract   := cKeyValue1
 CASE cTagName1==&quot;FACTS&quot; .AND. cKeyName1==&quot;SHIPPINGINSTRUCTION&quot;
      cDetailClauses    := cKeyValue1
 CASE cTagName1==&quot;FACTS&quot; .AND. cKeyName1==&quot;MOVETYPE&quot;
      cDetailMoveType   := cKeyValue1
 CASE cTagName1==&quot;FACTS&quot; .AND. cKeyName1==&quot;DESCRIPTIONOFGOODS&quot;
      cDetailDesc       := cKeyValue1
 CASE cTagName1==&quot;FACTS&quot; .AND. cKeyName1==&quot;FREIGHTCHARGETYPE&quot;
      cDetailCharges    := cKeyValue1
 CASE cTagName1==&quot;FACTS&quot; .AND. cKeyName1==&quot;DOCUMENTTYPE&quot;
      cDetailDocType    := cKeyValue1
 CASE cTagName1==&quot;FACTS&quot; .AND. cKeyName1==&quot;DOCUMENTTYPERATING&quot;
      cDetailDocRate    := cKeyValue1
 CASE cTagName1==&quot;FACTS&quot; .AND. cKeyName1==&quot;PACKAGETYPE&quot;
      cDetailPackage    := cKeyValue1
 CASE cTagName1==&quot;FACTS&quot; .AND. cKeyName1==&quot;PLACEOFFREIGHTPAYMENT&quot;
      cDetailFrtPay     := cKeyValue1
 CASE cTagName1==&quot;FACTS&quot; .AND. cKeyName1==&quot;PLACEOFBOLRELEASE&quot;
      cDetailPlaceRel   := cKeyValue1
 CASE cTagName1==&quot;FACTS&quot; .AND. cKeyName1==&quot;ITEMCODE&quot;
      cDetailItemCode   := cKeyValue1
 CASE cTagName1==&quot;FACTS&quot; .AND. cKeyName1==&quot;SHIPMENTTOTALPIECECOUNT&quot;
      cDetailTotalPcs   := cKeyValue1

 CASE cKeyName1==&quot;CONTACTDETAILS&quot;
      IF ! EMPTY( cName )
         DO CASE
            CASE cType=&quot;SHIPPER&quot;
                 cShipName         := cName
                 cShipAdd1         := cAddress1
                 cShipAdd2         := cAddress2
                 cShipCity         := cCity
                 cShipState        := cState
                 cShipZip          := cZip
                 cShipCountry      := cCountry

            CASE cType=&quot;CONSIGNEE&quot;
                 cConsName         := cName
                 cConsAdd1         := cAddress1
                 cConsAdd2         := cAddress2
                 cConsCity         := cCity
                 cConsState        := cState
                 cConsZip          := cZip
                 cConsCountry      := cCountry

            CASE cType=&quot;NOTIFYPARTY&quot;
                 cNotiName         := cName
                 cNotiAdd1         := cAddress1
                 cNotiAdd2         := cAddress2
                 cNotiCity         := cCity
                 cNotiState        := cState
                 cNotiZip          := cZip
                 cNotiCountry      := cCountry

            CASE cType=&quot;FORWARDER&quot;
                 cForwName         := cName
                 cForwAdd1         := cAddress1
                 cForwAdd2         := cAddress2
                 cForwCity         := cCity
                 cForwState        := cState
                 cForwZip          := cZip
                 cForwCountry      := cCountry
         ENDCASE
      ENDIF
      cName             := &quot;&quot;
      cType             := &quot;&quot;
      cAddress1         := &quot;&quot;
      cAddress2         := &quot;&quot;
      cCity             := &quot;&quot;
      cState            := &quot;&quot;
      cZip              := &quot;&quot;
      cCountry          := &quot;&quot;

 CASE cTagName1==&quot;CONTACTDETAILS&quot; .AND. cKeyName1==&quot;BUSINESSNAME&quot;
      cName             := cKeyValue1
 CASE cTagName1==&quot;CONTACTDETAILS&quot; .AND. cKeyName1==&quot;CONTACTDETAILTYPE&quot;
      cType             := cKeyValue1
 CASE cTagName1==&quot;CONTACTDETAILS&quot; .AND. cKeyName1==&quot;ADDRESSLINE1&quot;
      cAddress1         := cKeyValue1
 CASE cTagName1==&quot;CONTACTDETAILS&quot; .AND. cKeyName1==&quot;ADDRESSLINE2&quot;
      cAddress2         := cKeyValue1
 CASE cTagName1==&quot;CONTACTDETAILS&quot; .AND. cKeyName1==&quot;CITY&quot;
      cCity             := cKeyValue1
 CASE cTagName1==&quot;CONTACTDETAILS&quot; .AND. cKeyName1==&quot;STATE&quot;
      cState            := cKeyValue1
 CASE cTagName1==&quot;CONTACTDETAILS&quot; .AND. cKeyName1==&quot;POSTALCODE&quot;
      cZip              := cKeyValue1
 CASE cTagName1==&quot;CONTACTDETAILS&quot; .AND. cKeyName1==&quot;COUNTRY&quot;
      cCountry          := cKeyValue1

 CASE cTagName1==&quot;TRANSPORTITEM&quot; .AND. cKeyName1==&quot;ID&quot;
      cDetailTranspId   := cKeyValue1

 CASE cTagName1==&quot;TRANSITXMLKEY&quot; .AND. cKeyName1==&quot;VALUE&quot;
      cDetailTransitId  := cKeyValue1
      lTransitXmlKey    := .T.

 CASE cTagName1==&quot;SHIPPINGDETAILS&quot; .AND. cKeyName1==&quot;STEAMSHIPCOMPANY&quot;
      cSteamshipLine    := cKeyValue1
 CASE cTagName1==&quot;SHIPPINGDETAILS&quot; .AND. cKeyName1==&quot;VESSEL&quot;
      cVessel           := cKeyValue1
 CASE cTagName1==&quot;SHIPPINGDETAILS&quot; .AND. cKeyName1==&quot;VOYAGE&quot;
      cVoyage           := cKeyValue1
 CASE cTagName1==&quot;SHIPPINGDETAILS&quot; .AND. cKeyName1==&quot;PORTOFDEPARTURE&quot;
      cPortOfDeparture  := cKeyValue1
 CASE cTagName1==&quot;SHIPPINGDETAILS&quot; .AND. cKeyName1==&quot;PORTOFARRIVAL&quot;
      cPortOfArrival    := cKeyValue1

ENDCASE

RETURN (.T.)

*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: XML viewer
Posted: Thu Mar 07, 2013 09:01 AM

Darrell,

Please post the code for your function _Clean(), thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Re: XML viewer
Posted: Thu Mar 07, 2013 12:54 PM

Hi Antonio,

Here is the code

//-----------------------------------------------------------------------------
FUNCTION _Clean( cXmlData )

local cReturn := "" , ;
nX0 := 0 , ;
lPass := .T.

FOR nX0=1 TO LEN(cXmlData)
cChar := SUBSTR( cXmlData, nX0, 1 )
IF (ASC(cChar)>31) .AND. (ASC(cChar)<127)
cReturn += cChar
ELSE
IF "ABCHOU" $ Pmod
cReturn += SPACE(1)
ENDIF
lPass := .F.
ENDIF
NEXT nX0

IF ! lPass
MsgInfo( cXmlData )
ENDIF

RETURN (UPPER(cReturn))

*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: XML viewer
Posted: Fri Mar 08, 2013 10:19 AM

Darrell,

I have not tried it but its simple and seems fine, just a missing local cChar at the top.

How do you know that the DBFs are corrupted ? Does your app reports it when it tries to use them ?

Please email me the corrupted DBF, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Re: XML viewer
Posted: Fri Mar 08, 2013 01:10 PM

Hi Antonio,

I have sent you the DBF/FPT

*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Re: XML viewer
Posted: Mon Mar 11, 2013 08:12 AM

Hi Antonio,

Were you able to look at DBF/FPT I sent you? Do you think there could be an issue with TXmlDocument() and DBFCDX?

Sincerely,

*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: XML viewer
Posted: Tue Mar 12, 2013 01:39 AM

Darrell,

I have been reviewing the DBFs that you sent me, and I think we need to check if the problem comes from the reading of the XML data.

Please create a log file, at the same time that you save the data to the DBF, in example:

LogFile( "log.txt", { value1, ..., valueN } )
alias->field1 := value1
etc...

so we can see if the same error appears in log.txt

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Re: XML viewer
Posted: Wed Mar 13, 2013 04:00 AM

Hi Antonio,

There was an issue with memo fields, once I changed memo fields to character, the corruption issue went away.

Sincerely,

*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com