XML help

XML help

Postby cdmmaui » 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 := ""
cTagData := ""

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
User avatar
cdmmaui
 
Posts: 693
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: XML help

Postby cdmmaui » 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
User avatar
cdmmaui
 
Posts: 693
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: XML help

Postby cdmmaui » Thu Jun 06, 2019 1:14 pm

Hello,

I was able to figure it out.

Sincerely,
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 693
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 91 guests