Hi Sharon,
This SAX parser works by reading through your xml document and firing a call to your handler procedure every time an event occurs.
You have code for some events, but you are missing a crucial one - *XML_CHARS.
Consider the following trivial example:
<?xml version="1.0" ?>
<root>
<SKU>PT0110</SKU>
</root>
you should get the following calls:
*XML_START_DOCUMENT
*XML_START_ELEMENT - value passed is 'root'
*XML_START_ELEMENT - value passed is 'SKU'
*XML_CHARS - value passed is 'PT0110'
*XML_END_ELEMENT - value passed is 'SKU'
*XML_ENDELEMENT - value passed is 'root'
*XML_END_DOCUMENT
You are not handling what happens when the *XML_CHARS event occurs.
Also, you will not know what element the *XML_CHARS relates to unless you hold a variable telling you what the last *XML_START_ELEMENT had as the value. I would suggest you define a static variable in your sub-proc and set it to the value of the element name during the *XML_START_ELEMENT event and clear it during the *XML_END_ELEMENT. This is not the best way to go for more complicated documents though.
If you are to do this in a robust manner you should have a static variable containing the full path to your current element and add elements to the path in *XML_START_ELEMENT and remove them in *XML_END_ELEMENT.
For the above list of events you would set your path to look like this:
*XML_START_DOCUMENT - path = '/'
*XML_START_ELEMENT - path = 'root'
*XML_START_ELEMENT - path = '/root/SKU'
*XML_CHARS - path is unchanged but you get the value of SKU here as you are in /root/SKU
*XML_END_ELEMENT - path = '/root'
*XML_END_ELEMENT - path = '/'
*XML_END_DOCUMENT path = ''
Thus you would store the value of the SKU when a *XML_CHARS event is fired and your path = '/root/SKU'.
Hope this makes sense.
Cheers
Larry Ducie
_________________________________________________________________
It's simple! Sell your car for just $40 at CarPoint.com.au
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641&_t=762955845&_r=tig_OCT07&_m=EXT
As an Amazon Associate we earn from qualifying purchases.