I need to read in an XML file that comes all in one string. Here is an example with three records. The current string I am using is currently at length 968,273 and could easily be longer. We will be receiving these strings from an MQ server on our mainframe - we are fetching them to the PC and this is how they appear. The example below is only length 3830. I am wondering what would be the best way to read this in. I want to use only a single data step (at most) and have one record per item (there may be multiple items per ResolvedRequest - see that repeats.
White space in an XML file is generally ignored, so the fact that the file comes as one long string should not be horrible to deal with using the SAS XML Libname Engine (SXLE) -- as long as the file is well-formed. You would have to try with the WHOLE file -- not just a snippet of the XML -- because copying a snippet might make the XML be ill-formed -- but I'd recommend trying the XML Mapper application and/or the SAS XML Libname Engine.
1) the XML is well-formed and
2) the XML is valid (or follows some "rules" set forth in a DTD or Schema)
You should be able to read it with the SAS XML Libname Engine. Actually, SAS doesn't -really- care whether there is a DTD or Schema definition for the XML file -- but YOU should know or be able to find out whether the XML elements follow the rules set forth in a DTD or Schema. An XML file that conforms to a DTD or Schema will be easier to deal with in the long run because when/if you encounter a tag or element that you have not seen previously, you will be able to find out information from the DTD or Schema -- such as the proper nesting, the proper number of possible occurences, whether the element contains character data or other types of data (depending on whether the definition is coming from a DTD or a Schema).
If you cannot read your file directly with the XML Libname Engine (because it has too many nested levels), you may be able to "map" the nested levels to SAS variables using the XML Mapper to build an XML Map file. The difference between a "generic" XML file and a non-hierarchical file is described here: http://support.sas.com/onlinedoc/913/getDoc/en/engxml.hlp/a002592089.htm