Search code examples
excel-2010powerpivotatom-feeddatafeed

Import custom Atom feed in PowerPivot


Question: I have created a sample xml document containing data conforming to the atom 1.0 schema. When I import the contents of this file (for testing purposes) in PowerPivot, it creates columns for each atom element in each entry, instead of creating a column per content element. Why is this?

Background: A customer wants to import data from a web service which provides a feed that uses a custom XML schema that is not supported by PowerPivot. The service provides the ability for the caller to supply an XSLT template that will be applied to the feed. I am hoping to be able to transform this feed into a valid atom feed thereby allowing the customer to import data into PowerPivot.

Sample atom xml:

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
      xmlns="http://www.w3.org/2005/Atom"
      xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
   <title type="text">My Data Feed</title>
   <id>http://temp/feed</id>
   <updated>2012-12-13T00:00:00Z</updated>
   <entry>
      <id>http://temp/feed/1</id>
      <title type="text">Title</title>
      <author>
         <name>Author</name>
      </author>
      <updated>2012-12-13T00:00:00Z</updated>
      <content type="application/xml">
         <d:Name>John Smith</d:Name>
         <d:Address>Address</d:Address>
         <d:Zip>1234</d:Zip>
      </content>
   </entry>
</feed>

When imported into PowerPivot (selecting "From Data Feeds", clicking "Browse" and pointing out the xml file), it looks like this:

PowerPivot import result

I was excpecting three columns: Name, Address and Zip. If I change "Include Atom Elements" from Auto to False in the connection configuration, no columns are imported.


Solution

  • It seems I was just missing the m:properties element. Final result - also includes examples of null attributes and data types:

    <?xml version="1.0" encoding="UTF-8"?>
    <feed xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
          xmlns="http://www.w3.org/2005/Atom"
          xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
       <title type="text">My Data Feed</title>
       <id>http://temp/feed</id>
       <updated>2012-12-13T00:00:00Z</updated>
       <entry>
          <id>http://temp/feed/1</id>
          <title type="text">Title</title>
          <author>
             <name>Author</name>
          </author>
          <updated>2012-12-13T00:00:00Z</updated>
          <content type="application/xml">
    
             <!-- attributes placed under the properties element -->
             <m:properties>
                <d:Name>John Smith</d:Name>
                <d:Address>Address</d:Address>
                <d:Zip m:type="Edm.Int32">1234</d:Zip>
                <d:Comment m:null="true" />
             </m:properties>
    
          </content>
       </entry>
    </feed>