Import complex XML

Contributor fre
Posts: 35

Import complex XML

Dear Community


I need to import XML-structured data.

This is how the code looks like:


    <persoon xmlns:dossier="urn:be:vlaanderen:omgeving:dossier:v2" xsi:type="dossier:RechtsPersoon">
		<persoonId databron="KBO" externIdWaarde="0000000000" />
				<postadres gebruik="POA">
						<naam>no street</naam>
					<regio>Vlaams Gewest</regio>
				<medium aard="TEL">000000000</medium>
				<medium aard="EMAIL"></medium>
				<medium aard="FAX"></medium>
				<medium aard="GSM"></medium>
		<maatschappelijkeNaam>name ZZZ</maatschappelijkeNaam>
		<commercieleNaam>name XXX</commercieleNaam>


So far, I've tried 2 things:

- import via libname xxx xmlv2

- using XML Mapper


In both cases, SAS / XML mapper reports that it can not handle the XML.

Does anyone know how to import this data into a regular SAS dataset or what else I could try?


Any help or advice is highly appreciated.

Kind regards


Super User
Super User
Posts: 9,397

Re: Import complex XML

Well, one way, and I don't suggest it as the best, open the file in Excel, this will create an Excel table, then save as CSV.  Can't see why the mapper wouldn't handle it though, its a pretty simple table from what you show there.  

Contributor fre
Posts: 35

Re: Import complex XML

Hi RW9,

Thank you for your reply.

Seems like Excel cannot handle this xml.

+ I guess XML mapper is limited when it comes to more complex XML.


I'm wondering if SAS can handle such format. 

I don't know any other alternatives at the moment.

If anyone knows any alternative, feel free to reply...


Super User
Super User
Posts: 9,397

Re: Import complex XML

That XML you posted in your first post opened in Excel no problem for me.  

Contributor fre
Posts: 35

Re: Import complex XML

Thank you for clearing that out. 

I was using the import data in Excel (that didn't work), but indeed it works fine when you just use 'open file'.

Excel does a pretty good job, it's a pitty that SAS cannot do this.


For my purposes, I have 300 such XML files, all with different schemes.

So manually open each file in excel + convert to csv is not an option.


I'll have to look further to find something that can import all those files automatically.

Maybe VBA or something like that.


Super User
Super User
Posts: 9,397

Re: Import complex XML

Yes, just be careful as Excel likes to be "helpful"!  You could automate it by using VBA in Excel to load each file and save to CSV.  Seems a bit of a faff.  As mentioned XMLMapper should be able to deal with that as its not that complicated, maybe check with support as to why it says that, maybe you just need to stip something out.

When dealing with XML, you may be better off having a specific XLM tool the purpose.

Ask a Question
Discussion stats
  • 5 replies
  • 2 in conversation