I was reading through he use of XSLT to reverse the order of this podcast xml file and create a new one in reverse date order. I get the concept but dont understand how to perform this and where to place the xlst code for the reversing of this document.
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>FOOD & WINE with CHEF JAMIE GWEN</title>
<link>http://www.chefjamie.com/</link>
<language>en-us</language>
<copyright>Copyright ©Tastebud Entertainment, Inc. 2018</copyright>
<itunes:subtitle>Delicious conversation every Sunday about food and wine</itunes:subtitle>
<itunes:author>Chef Jamie Gwen</itunes:author>
<atom:link href="http://chefjamie.com/media/podcasts/Food-Wine-Podcasts/ChefJamie_podcast2.xml" rel="self" type="application/rss+xml" />
<webMaster>johnm#splithopsbrewing.com (John Merlino)</webMaster>
<itunes:summary>Syndicated on 70 Plus Stations across the United States and heard live every Sunday!</itunes:summary>
<description>Explore the culinary world with Jamie and meet top chefs, master sommeliers, cookbook authors and artisan food makers. Two hours of delicious conversation weekly !</description>
<itunes:explicit>No</itunes:explicit>
<itunes:image href="http://www.chefjamie.com/media/podcasts/Food-Wine-Podcasts/chefJamie_PodCast_image.jpg" />
<itunes:name>Chef Jamie Gwen</itunes:name>
<itunes:email>jamie#chefjamie.com</itunes:email>
<itunes:owner>Chef Jamie Gwen</itunes:owner>
<itunes:category text="Arts & Food"/>
<itunes:category text="Arts"/>
<item>
<title>Jan 8th, 2012</title>
<enclosure url="http://www.chefjamie.com/media/podcasts/Food-Wine-Podcasts/1-8-12.mp3" length="145178121" type="audio/mp3" />
<guid>http://www.chefjamie.com/media/podcasts/Food-Wine-Podcasts/1-8-12.mp3</guid>
<pubDate>Sun, 08 Jan 2012 13:00:00 GMT</pubDate>
<category>Podcasts</category>
<itunes:author>Chef Jamie Gwen</itunes:author>
<itunes:subtitle>Wine, Dine, & Balls</itunes:subtitle>
<itunes:summary>Happy New Year 2012.We are LIVE ON THE RADIO Daniel Holtzman of The Meatball Shop NYC shares melt-in-your mouth recipes for Meatballs of every kind. Sophie Gayot of www dot gayot dot com with highlights on Where to Dine in 2012.Jeff Scott, Author of Notes from a Kitchen with insight into the Culinary World.J. Lohr Winemaker Steve Peck fills our glasses with Cabernet and Pinot Noir</itunes:summary>
<itunes:explicit>No</itunes:explicit>
<itunes:duration>1:15</itunes:duration>
<itunes:keywords>food, cooking, wine, talk, cooking podcast, recipe podcast, diy cooking, learn to cook, learn new recipes, recipes, holiday, Christmas,</itunes:keywords>
</item>
<item>
<title>Jan 15th, 2012</title>
<enclosure url="http://www.chefjamie.com/media/podcasts/Food-Wine-Podcasts/1-15-12.mp3" length="47757770" type="audio/mp3" />
<guid>http://www.chefjamie.com/media/podcasts/Food-Wine-Podcasts/1-15-12.mp3</guid>
<pubDate>Sun, 15 Jan 2012 13:00:00 GMT</pubDate>
<category>Podcasts</category>
<itunes:author>Chef Jamie Gwen</itunes:author>
<itunes:subtitle>Family, Techniques, and Fitness</itunes:subtitle>
<itunes:summary>New Orleans Chef John Besh shares his Family Table. Editor Jack Bishop of Cooks Illustrated Talks about the Techniques of Home Cooking. Karen Page and Andrew Donenburg discuss their newest book on Food and Wine. Fitness Expert Lisa Lynn creates your Workout Strategy for 2012 </itunes:summary>
<itunes:explicit>No</itunes:explicit>
<itunes:duration>49:45</itunes:duration>
<itunes:keywords>food, cooking, wine, talk, cooking podcast, recipe podcast, diy cooking, learn to cook, learn new recipes, recipes, holiday, christmas,</itunes:keywords>
</item>
<item>
<title>Jan 22nd, 2012</title>
<enclosure url="http://www.chefjamie.com/media/podcasts/Food-Wine-Podcasts/1-22-12.mp3" length="18924125" type="audio/mp3" />
<guid>http://www.chefjamie.com/media/podcasts/Food-Wine-Podcasts/1-22-12.mp3</guid>
<pubDate>Sun, 22 Jan 2012 13:00:00 GMT</pubDate>
<category>Podcasts</category>
<itunes:author>Chef Jamie Gwen</itunes:author>
<itunes:subtitle>Produce, Asian Meals, and Ground Meat</itunes:subtitle>
<itunes:summary>Jamie and Lana Review the Top 10 Best Finds at The Fancy Food Show. Southern Chef Hugh Acheson on Seasonal Produce. Paul Martins American Grill Partner Brian Bennett shares his commitment to Local, Sustainable and Organic. Author Nina Simonds celebrates Chinese New Year with her "Simple Asian Meals". GM and Master Sommelier Michael Jordan LIVE from The Ranch! Jim Villas highlights the best recipes using Ground Meat for Superbowl! From his new cookbook "From The Ground Up" </itunes:summary>
<itunes:explicit>No</itunes:explicit>
<itunes:duration>01:18:51</itunes:duration>
<itunes:keywords>food, cooking, wine, talk, cooking podcast, recipe podcast, diy cooking, learn to cook, learn new recipes, recipes, holiday, Christmas,</itunes:keywords>
</item>
<item>
<title>Jan 29th, 2012</title>
<enclosure url="http://www.chefjamie.com/media/podcasts/Food-Wine-Podcasts/1-29-12.mp3" length="161118248" type="audio/mp3" />
<guid>http://www.chefjamie.com/media/podcasts/Food-Wine-Podcasts/1-29-12.mp3</guid>
<pubDate>Sun, 29 Jan 2012 13:00:00 GMT</pubDate>
<category>Podcasts</category>
<itunes:author>Chef Jamie Gwen</itunes:author>
<itunes:subtitle>Superbowl of Food, Salmon, Spices, and BBQ</itunes:subtitle>
<itunes:summary>Gridiron Grub: Lana and Jamie dish on the Superbowl of Food. Jeff Hall of Chapter One in Santa Ana highlights the Newest Artisan Spirits On The Market. Fish Farmer Stewart Hawthorne of Skuna Bay Salmon on Craft Raised Salmon. Chef Mark Garcia pumps of the Flavor of our dishes with the Flavor Forecast 2012 from McCormick Spices. Rick Browne,the King of BBQ, Smokes Us Out! </itunes:summary>
<itunes:explicit>No</itunes:explicit>
<itunes:duration>01:23:55</itunes:duration>
<itunes:keywords>food, cooking, Superbowl, talk, cooking podcast, recipe podcast, diy cooking, learn to cook, learn new recipes, recipes, bbq, spices</itunes:keywords>
</item>
<item>
<title>Feb 5th, 2012</title>
<enclosure url="http://www.chefjamie.com/media/podcasts/Food-Wine-Podcasts/2-5-12.mp3" length="80225176" type="audio/mp3" />
<guid>http://www.chefjamie.com/media/podcasts/Food-Wine-Podcasts/2-5-12.mp3</guid>
<pubDate>Sun, 05 Feb 2012 13:00:00 GMT</pubDate>
<category>Podcasts</category>
<itunes:author>Chef Jamie Gwen</itunes:author>
<itunes:subtitle>Superbowl Sunday Show</itunes:subtitle>
<itunes:summary>Ideas and Recipes for a Winning Superbowl Party Beer Truffles. Were having a party with PJ Clarkes Chef Johnny Church He is dishing on burger blends, oysters and the best fries. Arizona Biltmores Exec Chef Todd Sicolo on Wrights Restaurant and Big Game Food. Southern Chef Hugh Acheson shares his Modern Southern Style. Rick Rodgers with Sparkling Cocktail Inspiration </itunes:summary>
<itunes:explicit>No</itunes:explicit>
<itunes:duration>01:23:34</itunes:duration>
<itunes:keywords>food,cooking,superbowl,talk,cooking podcast,recipe podcast,diycooking,beer,truffles,superbowl</itunes:keywords>
</item>
<item>
<title>Feb 12th, 2012</title>
<enclosure url="http://www.chefjamie.com/media/podcasts/Food-Wine-Podcasts/2-12-12.mp3" length="81886563" type="audio/mp3" />
<guid>http://www.chefjamie.com/media/podcasts/Food-Wine-Podcasts/2-12-12.mp3</guid>
<pubDate>Sun, 12 Feb 2012 13:00:00 GMT</pubDate>
<category>Podcasts</category>
<itunes:author>Chef Jamie Gwen</itunes:author>
<itunes:subtitle>The Love Show</itunes:subtitle>
<itunes:summary>Spago Pastry Chef Sherry Yard gets us in the mood for love with Valentines Day Desserts. Chef Bernard Guillas of the Marine Room shares Recipes for Romance. Tanya Zuckerbrot Registered Dietitian and the creator of The F-Factor Diet divulges the Foods that you can Add To Your Diet to Lose Weight. Bake, Decorate, Celebrate! Wilton Baking Schools Nancy Siler gives us sweet Valentine Inspiration </itunes:summary>
<itunes:explicit>No</itunes:explicit>
<itunes:duration>01:25:18</itunes:duration>
<itunes:keywords>food, cooking, superbowl, talk, cooking podcast, recipe podcast, diy cooking, learn to cook, learn new recipes, recipes, sherry yard, romance, love</itunes:keywords>
</item>
</channel>
</rss>
Would like to take the programs and list them on another fresh xml document that can be hit showing the most recent show first.
If the items are already arranged in chronological order from oldest to newest, and you merely want to reverse the existing order, you can do:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- identity transform -->
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="channel">
<xsl:copy>
<xsl:apply-templates select="*[not(self::item)]"/>
<xsl:apply-templates select="item">
<xsl:sort select="position()" data-type="number" order="descending"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
The following code below pulls all the information I want; however, I want it to be sorted into an array so that each phone number is paired with the corresponding name, address, and description. I can't figure out a way to indent it to make it pull all 38 entries. Any help would be appreciated!
#import libraries
from selenium import webdriver
import csv
#driver path
driver = webdriver.Chrome('C:\Python27\Chromedriver\chromedriver.exe')
#fetch top Amsterdam restaurants
driver.get('http://www.eater.com/maps/best-amsterdam-restaurants')
for elem in driver.find_elements_by_xpath('.//h2[span[#class = "c-mapstack__card-index"]]'):
restname = elem.text
for address in driver.find_elements_by_class_name('c-mapstack__address'):
restaddress = address.text
for content in driver.find_elements_by_class_name('c-entry-content'):
restdescrip = content.text
eaterarray = [restname, restaddress, restdescrip]
print eaterarray
I am aware the indenting isn't right, and I've tried several configurations but I can't seem to get it to loop right in any configuration.
First of all i would like to inform you that if you do not want to provide the path of chromedriver in each script, just paste the "chromedriver.exe" under scripts folder of python..i.e,"C:\Python27\Scripts"
try this code, it will solve your problem:
from selenium import webdriver
driver = webdriver.Chrome()
driver.maximize_window()
#fetch top Amsterdam restaurants
driver.get('http://www.eater.com/maps/best-amsterdam-restaurants')
a=[]
b=[]
c=[]
for elem in driver.find_elements_by_xpath('.//h2[span[#class = "c-mapstack__card-index"]]'):
restname = elem.text.encode('ascii', 'ignore')
a.append(restname)
for address in driver.find_elements_by_class_name('c-mapstack__address'):
restaddress = address.text.encode('ascii', 'ignore').strip()
b.append(restaddress)
for content in driver.find_elements_by_class_name('c-entry-content'):
restdescrip = content.text.encode('ascii', 'ignore').strip()
c.append(restdescrip)
q=[(x,y) for x,y in zip(b, b[1:]) if '+31' in y]
q.insert(21,'Raadhuisstraat Amsterdam, Netherlands')
q.insert(25,'Leidsestraat 94 Amsterdam, North Holland 1017 PE, Netherlands')
d=c[1:]
new_dict= dict((a[i], (d[i],q[i])) for i in range(len(a)))
for k, v in new_dict.iteritems():
print k , v
it will print the output as:
22 Haringstal Ab Kromhout ("Contrary to popular belief, Dutch herring is not raw but salt-cured although the complex curing process does give it a raw finish on the tongue. First of the season herring are called Hollandse nieuwe and are usually available starting in early June. You can find herring stalls all over the city, but Haringstal Ab Kromhout come highly recommended. Order one au naturel or go for the traditional raw chopped onion and pickle accompaniment. Can't make it to Ab Kromhout? Kras Haring on Wittenburgergracht is also an excellent option. [$]", 'Raadhuisstraat Amsterdam, Netherlands')
25 Foodhallen ('Formerly a tram depot, De Foodhallen is now the place to get a taste of the Dutch street food scene. Theres something for everyone here: grilled cheese sandwiches (at Caulils), a bitterbal tasting (at De Ballenbar), burgers (at the Butcher), hotdogs (at Bulls & Dogs), Vietnamese street food (at Viet View), BBQ pork (at the Rough Kitchen), sweet tartlets (at Le Petit Gateau), Mediterranean snacks (at Maza), and lots more. [$$]', ('Bellamyplein 51\n1053 AT Amsterdam, Netherlands', '+31 6 29265037'))
3 Rotisserie Rijsel ('Rijsel serves Flemish and French classics like boeuf la mode, huzarensalade (Russian salad), presskop (head cheese), and rotisserie poussin, all prepared with the finest ingredients. This combined with a well-chosen and well-priced wine selection has put Rijsel on everybodys favourite list since its opening in 2012. Booking ahead is essential and (if on offer) dont think twice about ordering the Cte de Boeuf. [$$$]', ('Marcusstraat 52b\nAmsterdam, NoordHolland 1091TK, Netherlands', '+31 20 463 2142'))
9 Bord'eau - Restaurant Gastronomique ('If you can afford it, head to the two-Michelin-starred Bordeau for the ultimate fine-dining experience. Here, chef Richard van Oostenbrugge wows his guests with his incredibly skilled, classic technique-based cooking. Expect the finest produce, maximum flavors, exquisite sauces, and picture-perfect plates. In fact, Bordeaus signature apple dessert is the most photographed/Instagrammed dessert in Amsterdam. [$$$$]', ('Nieuwe Doelenstraat 2\nAmsterdam, North Holland 1012 CP, Netherlands', '+31 20 531 1705'))
10 Oriental City ('Located in Amsterdams Wallen area, Oriental City is a firm favorite with locals and Amsterdams Chinese community alike. Youll be tempted by much of the extensive menu, and Oriental Citys dim sum is among the best in Amsterdam. The restaurant has many tables divided over two floors, but still be prepared to stand in line on Saturdays. [$$$]', ('Oudezijds Voorburgwal 177-179\nAmsterdam, North Holland 1012 EV, Netherlands', '+31 20 626 8352'))
4 La Rive ('An Amsterdam fine-dining institution since the early 90s (and once the home of renowned Dutch chef Robert Kranenborg), since 2008, Rogr Rassin has been at the helm of La Rives kitchen. Dont be fooled by the traditional, ever-so-slightly formal dining room, because, au contraire, Rassins cooking is deliciously modern and seasonal. The dinner-only restaurant has a unique riverside location, so try to book a window table. [$$$$]', ('Professor Tulpplein 1\nAmsterdam, North Holland 1018 GX, Netherlands', '+31 20 520 3264'))
11 Restaurant Gebr. Hartering ('Part of Amsterdams new wave of casual and unpretentious restaurants, Gebr Hartering has helped shape the citys lively dining scene. The eatery is run by brothers Paul and Niek Hartering and the concept is very simple: hearty food cooked with great ingredients, to be enjoyed with a glass of fine wine. Theres a daily-changing menu, which includes the big-hitter Fleckvieh beef, grilled on charcoal. [$$$]', ('Peperstraat 10I\n1011 TL Amsterdam, Netherlands', '+31 20 421 0699'))
12 Nam Kee ('One of Amsterdams longest-running Chinese restaurants, Nam Kee is best known for its Peking duck window display and famous for its steamed oysters in black bean sauce fantastic oysters that owe their fame to the Dutch film (and novel) Oysters at Nam Kees. [$$$]', ('Zeedijk 111-113\nAmsterdam, North Holland 1012 AV, Netherlands', '+31 20 624 3470'))
15 Gebroeders Niemeijer ('Start your day with a cup of coffee (featuring Costadora beans) and a freshly-baked croissant at Gebr. Niemeijer bakery, or order one of its French-style breakfasts, with petit pains, croissants, marmalade, and jam. At lunchtime, Gebr. Niemeijer serves simple sandwiches and salads. Theres also a great selection of baked goods, and dont miss out on their baguettes (you know, for that Vondelpark picnic). [$]', ('Nieuwendijk 35\nAmsterdam, North Holland, Netherlands', '+31 20 707 6752'))
17 Toscanini ('Toscanini is the most-loved Italian restaurant in Amsterdams Jordaan, and with its 30-year history, probably one of the oldest, too. No pizzas here: Instead, expect a proper (seasonal) Italian menu with a choice of antipasti, primi, secondi, and dolci. Toscanini offers non-fussy food with great ingredients and maximum flavor, served in a wonderfully bustling setting. Its a great dinner spot and theres an excellent wine list, too. [$$$]', ('Lindengracht 75\nAmsterdam, North Holland 1015 KD, Netherlands', '+31 20 623 2813'))
26 FEBO ('Amsterdam is famous for its deep-fried snacks like kroket and bitterballen (both similar to croquettes) and frikandel, a type of sausage. At 75-year-old fast food chain Febo you can buy these snacks from an automat. There are branches scattered all over the city, so it shouldnt be too difficult to get your teeth into a frikandel or a kaassouffl, a pocket of deep-fried cheese. On Fridays and Saturdays some branches are open until 4 a.m., perfect for your wee-hour drunken munchies. [$]', 'Leidsestraat 94 Amsterdam, North Holland 1017 PE, Netherlands')
14 Restaurant Stork ('Hop on the IJplein ferry (near Central Station) for lunch or dinner at Stork, housed in a former Stork engines factory building on the north banks of the river IJ. Order sole or lobster with fries or tuck into a delicious plateau fruit de mer and enjoy the great views of the river. Storks riverside terrace offers a wonderful al fresco dining experience. [$$]', ('Gedempt Hamerkanaal 201\nAmsterdam, North Holland 1021 KP, Netherlands', '+31 20 634 4000'))
19 Proeflokaal Arendsnest ('For a taste of the burgeoning Dutch craft beer scene, get yourself a seat at the bar at Arendsnest. At this canal-side beer bar on the Herengracht, you can try over 30 Dutch beers on tap and no fewer than 100 bottled beers. Youll be spoiled with choices, but do try one of Jopen Brewerys award-winning beers, particularly the Extra Stout, which won a gold medal in the 2015 World Beer Awards. [$]', ('Herengracht 90\nAmsterdam, North Holland 1015 BS, Netherlands', '+31 20 421 2057'))
30 Thrill Grill ('With its first-rate burgers, Thrill Grill has rapidly become a household name for real burger lovers. Thrill Grill is the brainchild of veteran chef Robert Kranenborg, a local legend. The meat is from old Dutch dairy cows and cooked medium-rare. Get your teeth into a classic beef thriller or go for the salmon or veggie falafel burger. The branch on the Gerard Doustraat provides particularly lovely ambiance. [$$]', ('Gerard Doustraat 98\nAmsterdam, North Holland 1072VX, Netherlands', '+31 20 760 6750'))
27 Patisserie Holtkamp ('A family-owned pastry shop where Amsterdam locals go for their sweet treats, expect Patisserie Holtkamp to offer a small but superb range of French and Dutch patisserie, cakes, chocolates, and biscuits (no cupcakes here!). Holtkamp is also famous for its veal, shrimp, and cheese kroketten (croquettes), which are deep-fried to order in the shop. [$]', ('Vijzelgracht 15\nAmsterdam, North Holland 1017, Netherlands', '+31 20 624 8757'))
2 Brouwerij 't IJ ('This Amsterdam brewery has a unique canal-side location, right next to an old windmill, and the outdoor terrace is a popular hangout on sunny days. Around seven beers are available on tap, including the classic Zatte and Natte and often a special seasonal brew, too. A small selection of bar snacks is on offer, including the traditional Dutch Ossenworst, a raw and smoked beef sausage. [$]', ('Funenkade 7\nAmsterdam, North Holland 1018 AL, Netherlands', '+31 20 320 1786'))
24 Fromagerie Kef ('Cheesemonger Fromagerie Abraham Kef supplies many Michelin-starred restaurants in Amsterdam with cheese. The original shop (est. 1953) is on the Marnixstraat, but since 2014, a second branch also operates on the Czaar Peterstraat. On Sundays the Marnixstraat branch regularly organizes cheese and wine tastings. Kefs fantastic cheese selection (mainly made from raw milk) includes some magnificent aged Dutch cheeses. Dont leave without some Remeker. [$]', ('Marnixstraat\nAmsterdam, North Holland 1016 TJ, Netherlands', '+31 20 420 0097'))
18 Cafe De Klepel ('Quality wines and bistro food take the spotlight at Caf De Klepel, part of the recent Dutch bistronomie movement. This friendly and popular place is run by young sommelier duo Margot Los and Job Seuren (formerly of De Librije). Pop in for a glass of wine (at the bar) with some charcuterie or cheese. For the full experience, book a table and order De Klepels three-or four-course menu. [$$]', ('Prinsenstraat 22\nAmsterdam, North Holland 1015 DD, Netherlands', '+31 20 623 8244'))
36 Yamazato ('Yamazato provides an unexpected slice of Japan in the Dutch capital, including dining room views of a Japanese garden with a koi pond. In the evenings, the Michelin-starred Yamazato which is also in the Hotel Okura offers authentic kaiseki tasting menus, but you can also step in for lunch and order a bento box or the great value lunch menu (five courses for 50). An la carte menu including sushi and sashimi is available, too. [$$$-$$$$]', ('Ferdinand Bolstraat 333\nAmsterdam, North Holland 1072 LH, Netherlands', '+31 20 678 8351'))
38 Ron Gastrobar ('Amsterdams thriving dining scene owes a lot to Ron Blaauw. Three years ago, he relaunched his two-star restaurant into the more casual and wallet-friendly Ron Gastrobar, leaving his fine-dining years behind and at the same time launching a new trend. In fact, Michelin Netherlands is even talking about the Ron Blaauw effect. All dishes are priced at 15 (desserts 9) and the restaurant is lauded for its dry-aged barbecue steaks. [$$$]', ('Sophialaan 55 hs\nAmsterdam, North Holland 1075 BP, Netherlands', '+31 20 496 1943'))
13 Choux ('Relatively new on the Amsterdam dining scene but booked solid for dinner every night Choux serves natural wines and light, fresh cuisine, the latter always with a touch of comfort. Order three, four, or seven courses from the monthly-changing menu by chef Merijn van Berlo (including an excellent vegetarian option). For those who fail to snag a seat at dinner, theres also a three- or four- course menu available at lunchtime. [$$$]', ('De Ruijterkade 128\nAmsterdam, North Holland, Netherlands', '+31 6 16512364'))
20 La Perla ('If youre in the mood for a pizza, La Perla in the Jordaan is the place to go. The restaurant is split in two, with the pizzeria on one side of the street, and the huge wood-fired oven on the other. Try the classic Margherita (with buffalo mozzarella) or order the special porchetta di Ariccia, made with oven-roasted pork. [$$]', ('Tweede Tuindwarsstraat 14 & 53\nAmsterdam, North Holland 1015 RZ, Netherlands', '+31 20 624 8828'))
6 Slagerij de Leeuw ('Head to this butchers shop/deli if youre planning to cook a meal in your rental apartment. De Leeuw, the only gourmet butch shop in Amsterdam, offers a wide range of top-quality fresh meat and poultry, such as Wagyu and Rubia Gallega beef, Iberico pork, and Bresse chicken. But for your gourmet picnic, theres also a great selection of charcuterie, cold meats, pats, and other ready-made delicacies. [$$]', ('Utrechtsestraat 92\nAmsterdam, North Holland 1017 VS, Netherlands', '+31 20 623 0235'))
7 Librije's Zusje Amsterdam ('Literally the young sibling (zusje means little sister) of Jonnie Boers three-star restaurant De Librije in Zwolle, Librijes Zusje is located in the stunning Waldorf Astoria Hotel. Executive chef and De Librije alumnus Sidney Schutte has a modern and cutting-edge style of cooking, which shines through in all the dishes. The tasting menu has a hefty price tag, but its worth every cent. [$$$$]', ('Herengracht 542-556\nAmsterdam, North Holland 1017 CG, Netherlands', '+31 20 718 4643'))
34 Twenty Third Bar ('The Dutch cocktail scene is small but growing. The best option, if only for the amazing views, is Twenty Third Bar, situated on the 23rd floor of the Hotel Okura. The extensive cocktail list primarily features classics priced at 15 (champagne cocktails 19.50), and theres a small bar snack menu. Okuras notoriously expensive two-Michelin-starred restaurant Ciel Bleu is located on the same floor. [$$]', ('Ferdinand Bolstraat 333\nAmsterdam, North Holland, Netherlands', '+31 20 678 7450'))
16 Gs ('This funky place is an ideal spot for an American-style brunch which has grown increasingly popular here in recent years and provides respite for those in desperate need of a hangover Bloody Mary. Gs serves a full range of egg dishes; its chicken waffle burger is somewhat famous among locals. The Bloody Mary menu offers no fewer than 13 different versions. Gs has two branches. Consider booking a seat online in advance.', ('Goudsbloemstraat 91\nAmsterdam, North Holland 1015 JK, Netherlands', '+31 20 362 0030'))
8 Guts and Glory ('Guts & Glory a lively, stripped-down place just off Rembrandt Square opened by the super-talented chefs Guillaume de Beer and Freek van Noortwijk and their partner Johanneke van Iwaarden is one of the hottest places to eat in Amsterdam. Its signature is the single-ingredient menu called chapter, which changes every two to three months. After Chicken, Fish, Beef, Pork, and Vegetarian, de Beer and van Noortwijk will soon embark on chapter six: Italian. [$$-$$$]', ('Utrechtsestraat 6\nAmsterdam, North Holland, Netherlands', '+31 20 362 0030'))
31 Le Garage ('This iconic restaurant was founded by restaurateur Joop Braakhekke in 1990 in a former garage. Its famous for being a celebrity haunt, but perhaps equally famous for its dramatic red and black decor that hasnt changed since opening. Le Garage has a heavily French influenced menu (steak tartare, canard la presse, le flottante), but theres also room for modern dishes (squid carbonara, tuna pizza). [$$$]', ('Ruysdaelstraat 54-56\n1071 XE Amsterdam, Netherlands', '+31 20 679 7176'))
23 Broodjeszaak t Kuyltje ('Leisurely lunches are not part of everyday life in the Netherlands, but the Dutch do like a good sandwich, preferably on the go. The best place to get a taste of a Dutch-style sandwich is t Kuyltje. People queue up for its pastrami sandwich, but equally delicious is the Tartaar Speciaal (minced raw beef, onion, hardboiled egg) or the Halfom sandwich (half corned beef, half liver). [$]', ('Gasthuismolensteeg 9\nAmsterdam, North Holland 1016 AM, Netherlands', '+31 20 620 1045'))
35 BAK restaurant ('Bak is a pop-up turned brick-and-mortar restaurant located on the banks of the river IJ in Amsterdams recently re-developed Westelijk Havengebied area. In short: Expect serious food and serious wine, served in a laid-back setting. The menu reflects chef Benny Blistos love for seasonal and local ingredients, and on the wine list you can expect natural wines and quirky grape varieties. For lunch, BAK offers a very affordable three-course menu for 27. [$$]', ('Van Diemenstraat 410\nAmsterdam, North Holland 1013 CR, Netherlands', '+31 20 737 2553'))
21 Restaurant Breda ('A more upscale restaurant by game-changing chefs Guillaume de Beer and Freek van Noortwijk (compared to their other restaurant Guts & Glory, anyway), Bredas opening was greeted by widespread critical acclaim. Dishes are modern with creative flavor combinations, and you can taste the ambition of these young chefs. Sit down for dinner and order the Basic, Extra, or Full Monty tasting menu, and enjoy fine wines selected by sommelier Johanneke van Iwaarden. Its open daily for lunch and dinner. [$$$]', ('Singel 210\nAmsterdam, North Holland, Netherlands', '+31 20 622 5233'))
37 Restaurant Blauw ('Restaurant Blauw is an Indonesian spot renowned for its rijsttafel, which is the thing to order. Rijsttafel is a table-filling feast of small dishes, rice, and condiments, a hybrid Dutch-Indonesian tradition that originated during the Dutch colonial era. Theres a vegetarian rijsttafel option, and you can also order more traditional Indonesian dishes from the a la carte menu. Arrive hungry! [$$]', ('Amstelveenseweg 158-160\nAmsterdam, North Holland 1075 XN, Netherlands', '+31 20 675 5000'))
32 Par Hasard ('Herring and cheese aside, most people also think of fries when thinking of Amsterdam. The Belgian-style double-baked fries at Par Hasard (meaning: by accident) are regarded by many as the best fries in town. Grab an order with a traditional topping of mayonnaise, satay sauce, or zoervleis (a type of beef stew). [$]', ('Ceintuurbaan 113-115\nAmsterdam, North Holland 1072 EZ, Netherlands', '+31 20 471 4052'))
29 Conservatorium Brasserie & Lounge ('With its immense floor-to-ceiling windows and glass ceiling, this is hands-down the most impressive lobby-cum-all-day-dining-room in Amsterdam an essential part of the total experience at this cosmopolitan hotel. Enjoy drinks and snacks in the lounge area or go to the brasserie for lunch or dinner. Standout dishes include veal cheeks with mac and cheese, lobster au gratin, and apple crumble. Theres also a selection of sandwiches and steaks. [$$$]', ('Van Baerlestraat 27\nAmsterdam, North Holland 1070 LP, Netherlands', '+31 20 570 0000'))
1 Merkelbach ("Located in a former 18th-century coach house, Merkelbach's spectacular garden is hands-down the best outdoor dining experience in Amsterdam. The restaurant prides itself on following the principles of the Slow Food movement, so expect a seasonal menu with local ingredients. During the day you can walk in for coffee and apple pie, and theres a compact lunch menu. [$$]", ('Middenweg 72\nAmsterdam, North Holland 1097 BS, Netherlands', '+31 20 423 3930'))
28 Rijks at the Rijksmuseum ('Rijks brings a fresh approach to museum dining (its housed in the Rijksmuseum of Dutch art and history). On the menu designed by chef Joris Bijdendijk (formerly of the three-Michelin-starred Le Jardin de Sens and the one-starred Bridges) and his team find inventive small plates. Also featured are dishes by guest-chefs who cooked at Rijks, like Andr Chiang and Tim Raue. Definitely order the spit-roasted celeriac. [$$$]', ('Museumstraat 1\nAmsterdam, North Holland 1071 XX, Netherlands', '+31 20 674 7000'))
33 The Fat Dog ('For hot dogs, look no further than the Fat Dog, Amsterdams first-ever hot dog joint, opened by acclaimed chef/restaurateur Ron Blaauw in 2014. Order an all-pork frank with sauerkraut, mustard, and onion marmalade (called Gangs of New York) or go for the chicken Gado Gado hot dog with satay sauce, cabbage, and serundeng (spiced coconut flakes). Innovation doesnt stop there: The lamb dog comes with baba ganoush, and theres also a veggie dog. [$]', ('Ruysdaelkade 251\nAmsterdam, North Holland 1072 AX, Netherlands', '+31 20 221 6249'))
5 Patisserie Kuyt ('Follow locals and food obsessives from near and far to this fabulous patisserie for the finest pies, cakes, chocolates, biscuits, and eclairs. Kuyt also has a good selection of delicate savory pastries, quiches, and biscuits. The choice is overwhelming, but dont leave without a Appelschnitt, or better yet, enjoy any of the beautiful and delicious baked goods in the tea room. [$]', ('Utrechtsestraat 109\nAmsterdam, North Holland 1017 VL, Netherlands', '+31 20 623 4833'))
hope this is what you want
I am working with the below XML feed and am using structKeyExists and CFLoop to display the data it contains.
<cfoutput>
<cfxml variable="eating">
<catalog>
<results>10 </results>
<food id="bk101">
<initials type="thefirst" name="BK"/>
<initials type="thesecond" name="KB"/>
<keywords>Burger King, pie, hamburgers, fries, milkshakes </keywords>
</food>
<food id="bk102">
<initials type="thefirst" name="TB"/>
<initials type="thesecond" name="BT"/>
<keywords>Taco Bell, tacos, churros, burrito, gorditas </keywords>
</food>
<food id="bk103">
<keywords>Pizza Hut, pizza, cheese, garlic bread </keywords>
</food>
<food id="bk104">
<initials type="thefirst" name="CFA"/>
<initials type="thesecond" name="AFC"/>
<keywords>Chick-Fil-A, chicken, chicken wrap, sauce, Bananas Pudding Milkshake </keywords>
</food>
<food id="bk105">
<initials type="thefirst" name="PE"/>
<initials type="thesecond" name="EP"/>
<keywords>Panda Express, rice, egg rolls, general tso </keywords>
</food>
<food id="bk106">
<initials type="thefirst" name="SJ"/>
<initials type="thesecond" name="JS"/>
<keywords>Sakura Japan, rice, spring rolls, bento </keywords>
</food>
<food id="bk107">
<initials type="thefirst" name="FG"/>
<keywords>Five Guys, fries, burgers, hot dogs </keywords>
</food>
<food id="bk108">
<initials type="thefirst" name="TN"/>
<initials type="thesecond" name="NT"/>
<keywords>Tandoori Nights, biryani, chicken, egg rolls </keywords>
</food>
<food id="bk109">
<initials type="thefirst" name="HoK"/>
<keywords>House of Kabob, rice, bread, beef kabaob, chicken kabob </keywords>
</food>
<food id="bk110">
<initials type="thefirst" name="BF"/>
<initials type="thesecond" name="FB"/>
<keywords>Baja Fresh, quesadilla, soft taco, chili con queso </keywords>
</food>
</catalog>
</cfxml>
</cfoutput>
<cfset data = queryNew("id,initials,initials2,keywords","integer,varchar,varchar,varchar")>
<cfloop index="x" from="1" to="#eating.catalog.results.xmlText#">
<cfif structKeyExists(eating.catalog.food[x],"initials")>
<cfset queryAddRow(data)>
<cfset querySetCell(data,"id",x)>
<cfset querySetCell(data,"initials", eating.catalog.food[x].initials[1].xmlattributes.name )>
<cfset querySetCell(data,"initials2", eating.catalog.food[x].initials[2].xmlattributes.name )>
<cfset querySetCell(data,"keywords", eating.catalog.food[x].keywords )>
</cfif>
</cfloop>
<cfoutput query="data">
#id# - #initials# :: #initials2# :: #keywords# <br /><br />
</cfoutput>
You will notice there is one initial tag missing for Element 3 and two that are missing for Elements 7 and 9 in the XML feed . If the initials tags are added to the XML for Elements 3,7,9, the code works beautifully. However since they are missing, this causes an error to be thrown out an error.
What I would like to do is omit Element 3 (and all other entries which cause an error) from my results and prevent any errors from showing so the application result shows up like so:
1 - BK :: KB :: Burger King, pie, hamburgers, fries, milkshakes
2 - TB :: BT :: Taco Bell, tacos, churros, burrito, gorditas
4 - CFA :: AFC :: Chick-Fil-A, chicken, chicken wrap, sauce, Bananas Pudding Milkshake
5 - PE :: EP :: Panda Express, rice, egg rolls, general tso
6 - SJ :: JS :: Sakura Japan, rice, spring rolls, bento
8 - TN :: NT :: Tandoori Nights, biryani, chicken, egg rolls
10 - BF :: FB :: Baja Fresh, quesadilla, soft taco, chili con queso
Note my example is simplified, in actuality I am working with an XML feed with hundreds of elements. With that in mind, what am I doing wrong and how can I get the above to display correctly?
StructKeyExists() works just fine, but you need to check to ensure the second initials exists too. Adding ArrayLen(eating.catalog.food[x].initials) GT 1 (or EQ 2, if you know it'll always be 2) will solve it.
<cfif structKeyExists(eating.catalog.food[x],"initials") AND ArrayLen(eating.catalog.food[x].initials) GT 1>
With this fix, the example you gave outputs 1, 2, 4, 5, 6, 8, and 10. If you want to print 7 and 9, just move the check to here:
<cfif structKeyExists(eating.catalog.food[x],"initials")>
<cfset queryAddRow(data)>
<cfset querySetCell(data,"id",x)>
<cfset querySetCell(data,"initials", eating.catalog.food[x].initials[1].xmlattributes.name )>
<cfif ArrayLen(eating.catalog.food[x].initials) GT 1>
<cfset querySetCell(data,"initials2", eating.catalog.food[x].initials[2].xmlattributes.name )>
</cfif>
<cfset querySetCell(data,"keywords", eating.catalog.food[x].keywords )>
</cfif>