DATA Step, Macro, Functions and more

XMLV2 libname "Invalid file type"

Accepted Solution Solved
Reply
Regular Contributor
Posts: 150
Accepted Solution

XMLV2 libname "Invalid file type"

I have something odd that I don't seem to recall seeing.

 

I have a directory on machine: c:\temp\work

 

If I issue the following code:  libname TEST xmlv2 'c:\temp\work' ;

 

The error is:

 

"ERROR: Invalid file type"
"ERROR: Error in the LIBNAME statement"

 

If I issue the following code: libname TEST xmlv2 'c:\temp'

 

The library is allocated. Hence, XMLV2 does not like the second level directory.


If I use the XML engine vs XMLV2, the 2 level name is allocated.

 

Can anyone shed some light? My searches have come up empty.


Accepted Solutions
Solution
‎10-17-2017 11:10 AM
Community Manager
Posts: 3,463

Re: XMLV2 libname "Invalid file type"

You have to point this libname to an actual XML file, not a directory.  Assign one libname per XML file that you want to process.

 

libname TEST xmlv2 'c:\temp\work\file.xml' ;

 

Or 

filename source  'c:\temp\work\file.xml';
libname test xmlv2 xmlfileref=source;

 

View solution in original post


All Replies
Solution
‎10-17-2017 11:10 AM
Community Manager
Posts: 3,463

Re: XMLV2 libname "Invalid file type"

You have to point this libname to an actual XML file, not a directory.  Assign one libname per XML file that you want to process.

 

libname TEST xmlv2 'c:\temp\work\file.xml' ;

 

Or 

filename source  'c:\temp\work\file.xml';
libname test xmlv2 xmlfileref=source;

 

Regular Contributor
Posts: 150

Re: XMLV2 libname "Invalid file type"

Posted in reply to ChrisHemedinger

Thanks Chris. I have that working (direct to XML file) but do you know why SAS allows a 1 level directory but not 2 levels when it comes to XMLV2?

Community Manager
Posts: 3,463

Re: XMLV2 libname "Invalid file type"

Hey Alan -- I'm not familiar with that limitation/behavior.  Every time I've used the XML engine, I've specified a full path to an XML file and usually an XML map, since XML-in-the-wild is rarely structured as a usable data source.

Regular Contributor
Posts: 150

Re: XMLV2 libname "Invalid file type"

Posted in reply to ChrisHemedinger

The issue is in a dynamic XML world where the XML is somewhat unknown on arrival. If you have a simple libname statement:

 

libname TEST xmlv2 'c:\temp' ;

 

You can dump 1+ XML files into it. Any writing to that libname results in an XML file so it is very convenient as an XML workarea. Hence, I can now do something like:

 

data cars;

    set TEST.CARS ;

run;

 

And, if a cars.xml file is in c:\temp, it works. Likewise, if I write back to it:

 

data TEST.MYCARS;

    set cars;

run;

 

It will create the SAS dataset as an XML file.

 

Yes, it can be worked around but it is very convenient to just have a directory to mess with vs map files. I just don't understand why it will only take 1 level directory names. Weird.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 96 views
  • 2 likes
  • 2 in conversation