Importing XML Documents Using an XMLMap |
Using several methods, the XML engine can access an XML document that is referenced by a fileref. When using the URL access method to reference a fileref, you should also specify an XMLMap. Specifying an XMLMap causes the XML engine to process the XML document with a single pass of the file, rather than a double pass, which is what happens when you do not specify an XMLMap.
This example illustrates how to access an XML document by referencing a fileref and using the URL access method:
filename NHL url 'http://www.a.com/NHL.xml'; 1 filename MAP 'C:\My Documents\XML\NHL.map'; 2 libname NHL xml xmlmap=MAP; 3 proc copy indd=NHL outdd=work; 4 select NHL; run; proc print data=NHL; 5 run;
The first FILENAME statement assigns the fileref NHL to the XML document by using the URL access method.
The second FILENAME statement assigns the fileref MAP to the physical location of the XMLMap NHL.map.
The LIBNAME statement uses the fileref NHL to reference the XML document, specifies the XML engine, and uses the fileref MAP to reference the XMLMap.
The COPY procedure reads the XML document, and writes its content as a temporary SAS data set. When using the URL access method, you should include the step to create the SAS data set with either a PROC COPY or a DATA step.
The PRINT procedure prints the SAS data set WORK.NHL.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.