I've been experimenting with loading and writing to XML files in DI studio .
The example I tried had a structure as below
I created an XML library that referenced the XML file, and attempted to register the tables. When I first tried I could only see the Header, Body and Trailer as SAS objects; in order to get Table1, 2 and 3 I had to edit the XML file to delete all the information relating to the Header, Body and Trailer.
Is there a way to see all objects in an XML file with a hierarchy such as this?
My question is (and apologies if this is down to my lack of understanding of XML) - can I use a SAS XML library to register Tables_1, _2 and _3 without having to edit the XML? Or, is there some other way of using SAS to achieve this?
The DI Studio 4.21 user guide has a topic that might be relevant. The topic is mainly about how to create a web service job, but it includes some subtopics about XML inputs and outputs in jobs that might be relevant to your case:
DI Studio can read and write XML files directly. To read the XML file, you specify the XML map in the libname statement, and then point the library to an XML table that is readable with the map. To write XML files, in the access folder is an XML Writer transform that can either use a map or a template file to format the XML when writing it back out. You can see an example template file in the pre/post code tab of the XML writer transform if you want to see an example. We included it in the pre/post code so that users would have an example to start from.
Apologies for my recent absence, and thanks to those who've replied.
I've had XML mapper installed and have created a map file from my XML. I can view the data in a tabular form in the XML map application and can see that the example code generated in XML mapper follows the format Laurent de Walick describes earlier in this thread.
But, as Jo@SAS notes, I want to find the best way to incorporate this into DI studio.
I think the way to do it is via a library and created one which references the XML source file. I leave the XML type field blank, and on advanced options > XML Map tab navigate to the XML map I created using XML mapper.
This creates OK, but when I try to register the tables I get an error - "No tables were retrieved from your query. Your connection information may be incorrect."
When I look at the log I see that the libref was succesfully assigned but then get a partial message "encountered during XMLMap parsing occurred at or near line 16, column 36".
Anyone know what I'm doing wrong? any other options on the library, or is there some other way of using the XML map within DI studio?