XML to Prodataset - accessing root node data

Posted by Jens Dahlin on 23-Aug-2012 07:42

Another question about reading XML into ProDatasets.

How can I handle tags and attributes connected to the node element?

In the XML below, TrSearchRq would correspond to the DATASET itself, and there would be one table called Search_Criteria with fields ArrivalDate and DepartureDate. But how can I handle the tags Success and session_id and the attribute example?

<TrSearchRq example="testing">
  <Success>true</Success>
  <session_id>083667957901201223190810</session_id>
  <Search_Criteria>
    <ArrivalDate>2/9/2012</ArrivalDate>
    <DepartureDate>5/9/2012</DepartureDate>
  </Search_Criteria>
...
</TrSearchRq>

All Replies

Posted by Peter Judge on 23-Aug-2012 08:32

In the XML below, TrSearchRq would correspond to the DATASET itself, and

there would be one table called Search_Criteria with fields ArrivalDate

and DepartureDate. But how can I handle the tags Success and session_id

and the attribute example?

>

You need a table for the data you want to write for the TrSearchRq node(s). You can mark the dataset node as hidden, which makes the table node the top level node.

DEFINE TEMP-TABLE ttTrSearchRq XML-NODE-NAME 'TrSearchRq'

FIELD example AS CHARACTER XML-NODE-TYPE 'ATTRIBUTE'

FIELD success AS LOGICAL

FIELD session_id AS INT64 /?/

.

DEFINE DATASET TrSearchRq XML-NODE-TYPE 'HIDDEN'

FOR ttTrSearchRq

.

-- peter

Posted by Jens Dahlin on 23-Aug-2012 09:06

Is this not possible in 10.2B (should have mentioned version in original post of course)? From the documentation I see that XML-NODE-TYPE only seems to apply to buffer-field object handles?

Posted by Peter Judge on 23-Aug-2012 09:17

My apologies, that's also only in 11.

I suspect/fear you may have to resort to the 'old fashioned' SAX-READER approach. You can still populate a ProDataSet, it'll just be manual.

-- peter

Posted by Jens Dahlin on 23-Aug-2012 09:19

Time to upgrade!

This thread is closed