Import custom Atom feed in PowerPivot - excel-2010

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:
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.

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>

Related

Batch Delete Videos From YouTube Favorites Playlist

I am trying to batch delete videos from the user his YouTube favorites using the YouTube v2 API. (See also https://developers.google.com/youtube/2.0/developers_guide_protocol_batch_processing)
Posting videos to the favorites in batch works nicely; and I can also remove single videos from the favorites without problem (This rules out a problem with authentication).
My request body is as follows, where VIDEOID1 and VIDEOID2 are the <yt:favoriteId>Ids found in their corresponding video xml:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:yt='http://gdata.youtube.com/schemas/2007'>
<batch:operation type="delete"/>
<entry><id>VIDEOID1</id></entry>
<entry><id>VIDEOID2</id></entry>
</feed>
This is the response I get back however, where UserID ofcourse is the userID of the user and BatchID is the BatchID given by the service:
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom'>
<id>https://gdata.youtube.com/feeds/api/users/USERID/favorites/batch/BATCHID</id>
<updated>2014-01-31T14:50:54.948Z</updated>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#favorite'/>
<title>Batch Feed</title>
<entry xmlns:batch='http://schemas.google.com/gdata/batch'>
<id>VIDEOID1</id>
<updated>2014-01-31T14:50:54.948Z</updated>
<title>Error</title>
<content>Invalid entry Id/Uri</content>
<batch:status code='400' reason='Invalid entry Id/Uri'/>
</entry>
<entry xmlns:batch='http://schemas.google.com/gdata/batch'>
<id>VIDEOID2</id>
<updated>2014-01-31T14:50:54.949Z</updated>
<title>Error</title>
<content>Invalid entry Id/Uri</content>
<batch:status code='400' reason='Invalid entry Id/Uri'/>
</entry>
</feed>
It states Invalid entry Id/Uri for the videos I try to remove, while when I remove them by singular delete request with the same ID, it works.
Is batch deleting videos from favorites not supported, or am I missing something?
I've got it to work, thanks to this question and answer: Batch deleting videos using YouTube API and HTTpWebRequest
The trick was using the user its userId instead of default, and to use to complete video URL as id.
The batch URL looks like this:
https://gdata.youtube.com/feeds/api/users/USERID/favorites/batch?v=2&alt=json
The request looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:yt='http://gdata.youtube.com/schemas/2007'>
<batch:operation type="delete"/>
<entry>
<id>https://gdata.youtube.com/feeds/api/users/USERID/favorites/VIDEOID1?v=2</id>
</entry>
<entry>
<id>https://gdata.youtube.com/feeds/api/users/USERID/favorites/VIDEOID2?v=2</id>
</entry>
</feed>

Insert into Google Merchant data feed using Content API

I'm trying to insert some data into my merchant account data feed using the Content API. Using the code below, I've been given a "POST requests require a Content-length header. That’s all we know." error, but I've set the content length, so I'm really confused.
One theory I have is that it doesn't know where to put these requests, under my merchant account ID, I have two data feeds, and I'm not sure how to set it to enter into a given data feed.
The XML is stolen from here: https://developers.google.com/shopping-content/batch-operations
#feed = '<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/"
xmlns:g="http://base.google.com/ns/1.0"
xmlns:batch="http://schemas.google.com/gdata/batch">
<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:sc="http://schemas.google.com/structuredcontent/2009"
xmlns:scp="http://schemas.google.com/structuredcontent/2009/products"
xmlns:app="http://www.w3.org/2007/app">
<batch:operation type="INSERT"/>
<title>Switch 1</title>
<content type="text">A new item available...</content>
<link rel="alternate" type="text/html" href="http://www.example.com/sku123"/>
<sc:id>SKU123</sc:id>
<sc:content_language>en</sc:content_language>
<sc:target_country>US</sc:target_country>
<scp:google_product_category>Electronics > Networking > Hubs &
Switches</scp:google_product_category>
<scp:condition>new</scp:condition>
<scp:price unit="USD">25</scp:price>
<scp:availability>in stock</scp:availability>
</entry>
<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:sc="http://schemas.google.com/structuredcontent/2009"
xmlns:scp="http://schemas.google.com/structuredcontent/2009/products"
xmlns:app="http://www.w3.org/2007/app">
<batch:operation type="INSERT"/>
<title>Switch 2</title>
<content type="text">Another item available...</content>
<link rel="alternate" type="text/html" href="http://www.example.com/sku124"/>
<sc:id>SKU124</sc:id>
<sc:content_language>en</sc:content_language>
<sc:target_country>US</sc:target_country>
<scp:google_product_category>Electronics > Networking > Hubs &
Switches</scp:google_product_category>
<scp:condition>new</scp:condition>
<scp:price unit="USD">50</scp:price>
<scp:availability>in stock</scp:availability>
</entry>
</feed>'
http = HTTPClient.new
#output = http.post('https://content.googleapis.com/content/v1/<myMerchantID>/items/products/schema/batch', {},"content"=> #feed, "Content-length"=>#feed.length.to_s, "GData-Version"=> "1", "Authorization" => "AuthSub token=myToken", "Content-Type"=> "application/atom+xml")
Are you Authenticating prior to your post?
https://developers.google.com/shopping-content/getting-started/authentication

How to convert my xml file to kml file

In my iOS application,I have one xml file with thousands of locations data. I need to convert it to kml format to show heat maps on my map view. How can I convert it? Please give me guidelines for this conversion...
<?xml version="1.0"?>
<row id="1">
<id>101</id>
<name>Sharon Appartments</name>
<longitude>115.23412</longitude>
<latitude>34.734121</latitude>
<city>Dallas</city>
<state>California</state>
<country>USA</country>
</row>
<row id="2">
.
.
.
.
<row id="20000">
.
.
</row>
</xml>
Since you asked for guidelines, an example kml document looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name>New York City</name>
<description>New York City</description>
<Point>
<coordinates>-74.006393,40.714172,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
It seems you can keep the <name> field the same, you can combine the items in xml fields <city,<state>,<country> to klm field <address>city,state,country</address> or use it as a kml <description> tag (User-supplied content that appears in the description balloon ) as kml will use long and lat to determine a point if it is provided instead of using an address. Transform the xml <longitute>,<latitudite> need to be turned into a kml <point><cordinates>longitute,latatude</cordinates></point>
So you need to transform your klm document into something like this:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name>Sharon Appartments</name>
<description>Dallas, California, USA</description>
<Point>
<coordinates>115.23412,34.734121</coordinates>
</Point>
</Placemark>
<Placement>
Put item 2 details here
</Placement>
.
.
.
<Placement>
Put item 20000 details here
</Placement>
</Document>
</kml>
I got this from the https://developers.google.com/kml/documentation/kmlreference ,
Now for the heat map part, if you can transform your file into a list of lat and longs, you can put it into the python program on this webpage: http://jjguy.com/heatmap/ and it will produce a kml overlay for google maps based on that data, you need to combine that overlay with your kml file for your city data to get a complete map.

parseKml() error

I have noticed that parseKml() function does not parse KML file correctly. For example, if you have this bit of KML:
<ExtendedData>
<Data name="Offer">
<value>Apples</value>
<value>Potatoes</value>
<value>Tomatoes</value>
</Data>
</ExtendedData>
The parseKml() function will return a kmlObject that will contain only the last value, i.e. "Tomatoes":
Does anyone have a solution for this?
The structure for the type of extended data you are using is for name/value pairs. i.e. a single name with a single value.
<ExtendedData>
<Data name="string">
<displayName>...</displayName> <!-- string -->
<value>...</value> <!-- string -->
</Data>
</ExtendedData>
So what you are trying will not work. If you wish to add an arbitrary XML Data structure to a KML Feature then you would do it like this.
<ExtendedData xmlns:offer="http://yourserver.com/namespace">
<offer:item>Apples</offer:item>
<offer:item>Potatoes</offer:item>
<offer:item>Tomatoes</offer:item>
</ExtendedData>
Based on the data structure, the 'offer' XML Schema file (http://yourserver.com/namespace) would be something like.
<?xml version="1.0" encoding="utf-16"?>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="item" type="xsd:string" />
</xsd:schema>
I believe the <Data> element can only contain a single <value> - according to the docs, the "<Data> element allows you to add untyped name/value pairs to the user data associated with a given Feature."
So in your case, it's picking up the last <value> element only. You might find another way to add your custom data here: https://developers.google.com/kml/documentation/extendeddata

Using OmniXML and Delphi, how do I locate an element by its attribute and change another element in node?

Using OmniXML and Delphi, I would like to locate an element and change another element in the node. For example, in the xml listing below, I would like to locate /first-name = 'Joe1' and then locate and change the /price from 1200 to 10.
I've tried using XPathSelect but I can not seem to specify the /first-name.
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="myfile.xsl" ?>
<bookstore specialty="novel">
<book style="autobiography">
<author>
<first-name>Joe1</first-name>
<last-name>Bob</last-name>
<award>Trenton Literary Review Honorable Mention</award>
</author>
<price>1200</price>
</book>
<book style="textbook">
<author>
<first-name>Mary</first-name>
<last-name>Bob</last-name>
<publication>Selected Short Stories of
<first-name>Mary</first-name>
<last-name>Bob</last-name>
</publication>
</author>
<editor>
<first-name>Britney</first-name>
<last-name>Bob</last-name>
</editor>
<price>55</price>
</book>
</bookstore>
Use //book[author/first-name = "Joe1" ] as your XPathSelect query to get the node, and then access the subnode Price from that node to change it.

Resources