FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour XML help
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
XML help
Posted: Thu Jun 06, 2019 12:04 PM

Hello Everyone,

I am trying to read the following XML message with sample code below, however
<Transaction>
<MessageDate>2019-06-05T02:01:42</MessageDate>
<MessageFunction>DELTA</MessageFunction>
<Carrier>HLCU</Carrier>
<Schs Vsl="BARRY TRADER" Lloyds="9658446" Valid="Y" Voy="0011E" Service="IRA">
<Sch Id="864ccf4592f7e34d58b70f3212ea5b08" Act="C">
<Orig Type="POL" Code="SGSIN" Departs="2019-06-28T06:00:00"/>
<Dest Type="POD" Code="PHDVO" Arrives="2019-07-05T08:00:00"/>
</Sch>
<Sch Id="8528968ce125968263df42d67c05e57a" Act="C">
<Orig Type="POL" Code="SGSIN" Departs="2019-06-28T06:00:00"/>
<Dest Type="POD" Code="PHGES" Arrives="2019-07-03T10:00:00"/>
</Sch>
<Sch Id="4df56a5cace6e91d73115fbc47827d9b" Act="C">
<Orig Type="POL" Code="PHGES" Departs="2019-07-04T20:00:00"/>
<Dest Type="POD" Code="PHDVO" Arrives="2019-07-05T08:00:00"/>
</Sch>
</Schs>
</Transaction>

/*
Sample Code
/
*
nXmlMax := LEN(aXmlFile)
cXmlFile := aXmlFile[nXmlMax,1]
cStart := TIME()
hFile := FOpen( cSource + cXmlFile )
oXmlDoc := TXmlDocument():New( hFile )
oXmlIter := TXmlIterator():New( oXmlDoc:oRoot )

 WHILE .T.
     oTagActual = oXmlIter:Next()
     If oTagActual != nil
        cTagName := &quot;&quot;
        cTagData := &quot;&quot;

        IF (oTagActual:cName != nil)
           cTagName := oTagActual:cName
        ENDIF
        IF (oTagActual:cData != nil)
           cTagData := oTagActual:cData
        ENDIF
                    cXmlText += cTagName + '=' + cTagData + cEol
                    nXMlItems++
              ELSE
                    EXIT
             ENDIF
  End
  FCLOSE( hFile )
        cEnd := TIME()

        MEMOWRIT( 'xmldata.txt', cXmlText )
        MsgInfo( cStart + cEol + cEnd + cEol + LTRIM(STR(nXmlItems,9)) )
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Re: XML help
Posted: Thu Jun 06, 2019 12:07 PM
Sorry, my question is how do I get values for the following in BOLD:

<Schs
Vsl="BARRY TRADER"
Lloyds="9658446"
Valid="Y"
Voy="0011E"
Service="IRA"
>
<Sch
Id="864ccf4592f7e34d58b70f3212ea5b08"
Act="C"
>
<Orig
Type="POL"
Code="SGSIN"
Departs="2019-06-28T06:00:00"

/>
<Dest
Type="POD"
Code="PHDVO"
Arrives="2019-07-05T08:00:00"

/>
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Re: XML help
Posted: Thu Jun 06, 2019 01:14 PM

Hello,

I was able to figure it out.

Sincerely,

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

Continue the discussion