What is the best way to parse XML doc in Progress?

b-707

Member
Hi all.
I have an X-DOCUMENT loaded in my routine. Big, good, valid XML object. I am looking for a best way to parse it. How should I call a node by name and not by the number in the collection?

Thank You...
 
if you are looking for something like xpath then that's not there, you have to parse the tree recursively using x-noderef:num-children... if you do know the xml structure, or at least part of what you are interested in the easiest way is to define a temp-table/dataset that maps to that structure and use read-xml (which depending on the progress version you have might be available or not).
 
Thank you.
From what I read this night I see that the alternative is using SAX. In my case the only think I need is to suck the data from this XML and to allocate into the native DB. I don't see any advantages from using SAX. Do you?

P.S. Is it possible at least to call attributes by name?

P.S.S I am so frustrated XPath is not here......
 
Thank you.
From what I read this night I see that the alternative is using SAX. In my case the only think I need is to suck the data from this XML and to allocate into the native DB. I don't see any advantages from using SAX. Do you?

different parsing techniques, sax is read-only and most important forward-only but it's far more resource friendly as it parse the input stream instead of loading the complete document tree in memory as dom does... I usually go for sax when I expect large documents to pop-in.

P.S. Is it possible at least to call attributes by name?

yes, you can do that for dom or sax parser.

P.S.S I am so frustrated XPath is not here......
:) still, if you are in a OE10+ version you might want to take a look to read-xml methods
 
So SAX looks better for me... The only my concern - we use OO approach. As far as I remember any attempt to allocate Procedure in the .cls file didn't compile. May be I am missing something? Or should I add the procedure as an include? I am pretty far of my desk - cannot check this myself...
 
So SAX looks better for me... The only my concern - we use OO approach. As far as I remember any attempt to allocate Procedure in the .cls file didn't compile. May be I am missing something? Or should I add the procedure as an include? I am pretty far of my desk - cannot check this myself...

well, try to get closer if you plan on doing some work :)

you can't attach methods to sax call-backs, it has to be a procedure with sax specific internal entries (start element, end element, characters)... you can start the handler procedure as persistent and from that call-back to OO methods; give it the class instance as input parameter – run saxHandler (this-object).
 
So, I created XML in Progress.
Using method hDoc:SAVE("LONGCHAR",uFields). getting the xml syntax and sent it to a web service. The web service doesn't like the
<?xml version="1.0" ?> at the beginning of it. Is there any way to get rid of it?
 
Back
Top