Monday, February 06, 2012

Making mySQL XML Exports Friendlier to OpenInsight – Part 1

If you have ever utlized the mySQL Query Browser and exported a resultset to XML, you may have notice the format that the XML file is in.  See the example below:

If you have ever tried to import XML like this into OI without a schema (which isn't easily provided), then you know there is some formatting that needs to be done to the XML.  I personally love using the OI function Get_XML_Value().  However, that function ceases to work with this formatting.

So, to get around this, I whipped up a quick down and dirty piece of code that formats the XML into a more OI friendly format.  Now I realize there are always other ways of doing this, so — this is just another way.  Comments are always welcome on better ways too!

You will also need the following code for the Get_Last_Value subroutine.  This subroutine returns the last position in a delimited string, just another routine to use instead of the Count Function.

You will need to change the values for the variables — File and Tags.  So that is how you can format your XML for easy import into OI.   Next in the series will be the code to import this formatted XML file into OpenInsight.

Leave a Reply