I’m building a generic helper class to flatten an ADOMD data set to a data table for easier consumption by default and third party .NET controls. I can’t rely on the Load method of the data table, nor the CellSet object as in some cases not all the information is persisted; datatypes and top level hierarchies to name two.
To persist all of the information I need to traverse the actual xml dataset returned by the ExecuteXMLReader method of the ADOMDCommand object.
I don’t use xml enough these days to remember all the nuances with namespaces and it took me a little while to work out what to set the namespaces to in order for the ‘SelectNodes’ method to work.
Below is the code snippet I used to ensure the output from the ExecuteXmlReader method is fully traversable.
// Execute the command returning the XML data set
XmlReader reader = command.ExecuteXmlReader();
// Load the object into an XML document
XmlDocument xml = new XmlDocument();
xml.Load(reader);
// Create an XML namespace manager
System.Xml.XmlNamespaceManager nsManager=new XmlNamespaceManager(xml.NameTable);
// Add the namepsaces to the manager
nsManager.AddNamespace(“defaultNS”,”urn:schemas-microsoft-com:xml-analysis:mddataset”);
nsManager.AddNamespace(“xsi”,http://www.w3.org/2001/XMLSchema-instance);
nsManager.AddNamespace(“xsd”,http://www.w3.org/2001/XMLSchema);
// Return a list of nodes that represent the row information
XmlNodeList rows = xml.SelectNodes(“defaultNS:root/defaultNS:Axes/defaultNS:Axis[@name =’Axis1′]”, nsManager);
This kb article helped me out a bit:
http://support.microsoft.com/default.aspx?scid=kb;en-gb;q318545
There are some more goodies included in my helper class that I will blog about in the future, once it’s stable !
Introduction to Data Wrangler in Microsoft Fabric
What is Data Wrangler? A key selling point of Microsoft Fabric is the Data Science
Jul
Autogen Power BI Model in Tabular Editor
In the realm of business intelligence, Power BI has emerged as a powerful tool for
Jul
Microsoft Healthcare Accelerator for Fabric
Microsoft released the Healthcare Data Solutions in Microsoft Fabric in Q1 2024. It was introduced
Jul
Unlock the Power of Colour: Make Your Power BI Reports Pop
Colour is a powerful visual tool that can enhance the appeal and readability of your
Jul
Python vs. PySpark: Navigating Data Analytics in Databricks – Part 2
Part 2: Exploring Advanced Functionalities in Databricks Welcome back to our Databricks journey! In this
May
GPT-4 with Vision vs Custom Vision in Anomaly Detection
Businesses today are generating data at an unprecedented rate. Automated processing of data is essential
May
Exploring DALL·E Capabilities
What is DALL·E? DALL·E is text-to-image generation system developed by OpenAI using deep learning methodologies.
May
Using Copilot Studio to Develop a HR Policy Bot
The next addition to Microsoft’s generative AI and large language model tools is Microsoft Copilot
Apr