| Return to previous page
|
Use XMLCONCATENATE=YES cautiously. If an XML document consists of concatenated XML documents, the content is not standard XML construction. The intent of the option is to provide convenience, not to encourage invalid XML format.
This example imports the following file named ConcatStudents.XML, which consists of two XML documents:
<?xml version="1.0" ?> <LIBRARY> <STUDENTS> <ID>1345</ID> <NAME>Linda Kay</NAME> <SCHOOL>Bellaire</SCHOOL> <CITY>Houston</CITY> </STUDENTS> <STUDENTS> <ID>2456</ID> <NAME>Chas Wofford</NAME> <SCHOOL>Sam Houston</SCHOOL> <CITY>Houston</CITY> </STUDENTS> <STUDENTS> <ID>3567</ID> <NAME>Jerry Kolar</NAME> <SCHOOL>Sharpstown</SCHOOL> <CITY>Houston</CITY> </STUDENTS> </LIBRARY> <?xml version="1.0" ?> <LIBRARY> <STUDENTS> <ID>1234</ID> <NAME>Brad Martin</NAME> <SCHOOL>Reagan</SCHOOL> <CITY>Austin</CITY> </STUDENTS> <STUDENTS> <ID>2345</ID> <NAME>Zac Harvell</NAME> <SCHOOL>Westwood</SCHOOL> <CITY>Austin</CITY> </STUDENTS> <STUDENTS> <ID>3456</ID> <NAME>Walter Smith</NAME> <SCHOOL>Bowie</SCHOOL> <CITY>Austin</CITY> </STUDENTS> </LIBRARY>
The default XML engine behavior does not support concatenated XML documents. (The default is XMLCONCATENATE=NO.) Therefore, the following SAS program imports the first XML document, which consists of three observations, then produces an error for the second XML document:
libname concat xml '/u/My Documents/xml/ConcatStudents.xml'; proc datasets library=concat;SAS Log Output
NOTE: Libref CONCAT was successfully assigned as follows:
Engine: XML
Physical Name: /u/My Documents/xml/ConcatStudents.xml
20 proc datasets library=concat;
ERROR: "xml" is illegal as a processing-instruction target name.
encountered during XMLMap parsing
occurred at or near line 23, column 7
Directory
Libref CONCAT
Engine XML
Physical Name /u/My Documents/xml/ConcatStudents.xml
XMLType GENERIC
XMLMap NO XMLMAP IN EFFECT
Member
# Name Type
1 STUDENTS DATA
libname concat xml '/u/My Documents/xml/ConcatStudents.xml' xmlconcatenate=yes; proc print data=concat.students; run;PROC PRINT Output
The SAS System 1
Obs CITY SCHOOL NAME ID
1 Houston Bellaire Linda Kay 1345
2 Houston Sam Houston Chas Wofford 2456
3 Houston Sharpstown Jerry Kolar 3567
4 Austin Reagan Brad Martin 1234
5 Austin Westwood Zac Harvell 2345
6 Austin Bowie Walter Smith 3456