Back when EDI was the pre-XML standard, it was necessary to write a low-level routine using FOPEN(), FGET(), etc. commands to Parse the data out of the EDI file (a text file).
Now that XML is here, you will have to do the same approach with the XML file (it is really just a text file).
Developing the text parser can be a tedious process and you may have to build your code to pro-actively anticipate possible variations in the XML text (e.g. new fields, etc.), but when done, it should work well.
Good Luck,
JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
[ ]
Here is a function that I use to find a line in a low level text file.
******************************
*
* Find line containing search string
*
******************************
*
* Finds next occurance of qStr in existing open file designated by qHandle.
* Automatically increments file pointer to end of last line processed.
* Always begins at current file pointer position in file.
* Continues until carriage return found or maximum bytes searched.
*
* SYNTAX:
* = LLFindLine(qHandle, qStr[, qLine[, qBytes]])
*
* ENTRY:
* qHandle N: File handle of file to be examined
* qStr C: String to find
* qLine C: "l" if left portion of line wanted
* C: "r" if right portion of line wanted
* Defaults to line containing qStr
* qBytes N: Number of bytes to search from current file position
* Defaults to 762 bytes
*
* EXIT:
*
* RETURNs:
* '' = String not found
* string = Part of file wanted
*
******************************
PARAMETER qHandle, qStr, qLine, qBytes
PRIVATE ALL LIKE z*
zfound = 0
IF TYPE('qBytes') <> 'N'
qBytes = 762
ENDIF
z = ASC(FORMAT(qLine))
DO WHILE EMPTY(zfound)
zthisline = FGETS(qHandle, qBytes)
IF FEOF(qHandle) AND EMPTY(zthisline)
EXIT
ENDIF
zfound = AT(qStr, zthisline)
ENDDO
DO CASE
CASE EMPTY(zfound)
zfound = ''
CASE z = 82 && Right
zfound = SUBSTR(zthisline, zfound)
CASE z = 76 && Left
zfound = LEFT(zthisline, zfound - 1)
OTHERWISE
zfound = zthisline
ENDCASE
RETURN zfound
The line in red uses one of my handy dandy functions which is way to long to put here. So, you will need to change that line to something that sets z to the ASCII value of qLine. Be aware that in the default mode that qLine can be .F., so a simple ASC() will not work.
Thnaks for the feedback. I had to write a parser to pull the needed data byte by byte. The file had no CR or LF so I had to scan each byte to find the tag starts and treat it as a new line then process previous line for wanted data.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.