You are here:  » Parsing Feed with nested groups


Parsing Feed with nested groups

Submitted by shawnwalters on Sat, 2011-08-20 01:02 in

Ok, here is a snippet of code:

<collection query="blockbuster" origin="explicit">
<group category="web" group-by="relevance" type="main">
<details>
<paid-links>2</paid-links>
<unpaid-links>10</unpaid-links>
<max-count>13100000</max-count>
</details>
<group group-by="relevance">
<details>
<results-count>13100000</results-count>
<results-start>1</results-start>
<results-end>10</results-end>
</details>
<result>
<site-link>
http://url.com
</site-link>
<paid>false</paid>
<display-url>http://www.blah.com/</display-url>
<title>
Movies | New Releases | DVD Rental | Movie Trailers | Movie ...
</title>
<description>
Rent, buy, or download over 100,000 movies including new release movies at Blockbuster.com. Your source for movie reviews, trailers, ratings, and more.
</description>
</result>
<result>
<site-link>
http://url.com
</site-link>
<paid>false</paid>
<display-url>blah</display-url>
<title>
Blockbuster Inc. - Wikipedia, the free encyclopedia
</title>
<description>
Blockbuster L.L.C (formerly "Blockbuster Inc.") is an American-based provider of home video and video game rental services, originally through video rental shops (both owned ...
</description>
</result>
<result>
<site-link>
http://url.com
</site-link>
<paid>false</paid>
<display-url>
blah
</display-url>
<title>
Blockbuster (entertainment) - Wikipedia, the free encyclopedia
</title>
<description>
Blockbuster, as applied to film or theatre, denotes a very popular and/or successful production. The entertainment industry use was originally theatrical slang referring to ...
</description>
</result>
<result>
<site-link>
http://url.com
</site-link>
<paid>false</paid>
<display-url>blah</display-url>
<title>
$1 DVD Movie Rentals, Rent DVDs Online, Find a DVD Machine ...
</title>
<description>
$1 DVD Rentals from Blockbuster Express. See all of the new DVD movie releases, sign up for a free DVD movie rental, and find a DVD machine at a grocery store near you.
</description>
</result>
<result>
<site-link>
http://url.com
</site-link>
<paid>false</paid>
<display-url>blah</display-url>
<title>Blockbuster Blog</title>
<description>
The Official Blog of Blockbuster Inc — Featuring news and musings about entertainment and our company. We talk new releases, DVDs, Blu-ray, video games, TV shows, and ...
</description>
</result>
<result>
<site-link>
http://url.com
</site-link>
<paid>false</paid>
<display-url>blah</display-url>
<title>Blockbuster (@blockbuster) on Twitter</title>
<description>
Get short, timely messages from Blockbuster. Twitter is a rich source of instantly updated information. It's easy to stay updated on an incredibly wide variety of topics.
</description>
</result>
<result>
<site-link>
http://url.com
</site-link>
<paid>false</paid>
<display-url>blah</display-url>
<title>Social Standing ...</title>
<description>
Blockbuster 68 70 2 : CBS 69 71 2 : MySpace 74 76 2 : Sirius 59 61 2 : WebMD
</description>
</result>
<result>
<site-link>
http://url.com
</site-link>
<paid>false</paid>
<display-url>blah</display-url>
<title>Symbol Lookup from Yahoo! Finance</title>
<description>
Search for ticker symbols for Stocks, Mutual Funds, ETFs, Indices and Futures on Yahoo! Finance.
</description>
</result>
<result>
<site-link>
http://url.com
</site-link>
<paid>false</paid>
<display-url>
blah
</display-url>
<title>
Amazon.com: Blockbuster (9780743239912): Tom Shone: Books
</title>
<description>
Shone's first book is an entertaining chronological survey of top-grossing films during the past 30 summers, beginning with Universal's Jaws (1975). The Steven ...
</description>
</result>
<result>
<site-link>
http://url.com
</site-link>
<paid>false</paid>
<display-url>blah</display-url>
<title>
Blockbuster News & Latest Blockbuster Headlines ...
</title>
<description>
Blockbuster articles, stories, news and information. ... Last year, 24/7 Wall St. put together a list of CEOs who need to retire, basing its judgment on quarterly earnings ...
</description>
</result>
</group>
</group>
<group category="web" group-by="relevance" type="extra-cat" region="top">
<result>
<site-link>
http://url.com
</site-link>
<paid>true</paid>
<display-url>blah</display-url>
<title>Watch Movies Online</title>
<description>
Free Trial. Unlimited Movies. $7.99/mo. No Extra Fees.
</description>
<seller-ratings-advertiser-info>netflix.com is rated</seller-ratings-advertiser-info>
<seller-ratings-rating>4.5</seller-ratings-rating>
<seller-ratings-review-count>1,215 reviews</seller-ratings-review-count>
<seller-ratings-source-url>
http://www.google.com/products/seller?zmi=blah1.com
</seller-ratings-source-url>
</result>
<result>
<site-link>
http://url.com
</site-link>
<paid>true</paid>
<display-url>blah</display-url>
<title>Try Total Access</title>
<description>
Switch to Blockbuster Total Access Today! Get 30 Days Free.
</description>
<seller-ratings-advertiser-info>blockbuster.com is rated</seller-ratings-advertiser-info>
<seller-ratings-rating>4</seller-ratings-rating>
<seller-ratings-review-count>284 reviews</seller-ratings-review-count>
<seller-ratings-source-url>
http://www.google.com/products/seller?zmi=blah.com
</seller-ratings-source-url>
</result>
</group>
</collection>

My current set is xml|SEARCH-RESULTS/COLLECTION/GROUP/GROUP/ , however it does not read/place the "seller-ratings" results correctly. How do I code it so that magicparser can read and associate all the data within one "result" "/result" tag? Example:

<result>
<site-link>
http://url.com
</site-link>
<paid>true</paid>
<display-url>blah</display-url>
<title>Watch Movies Online</title>
<description>
Free Trial. Unlimited Movies. $7.99/mo. No Extra Fees.
</description>
<seller-ratings-advertiser-info>netflix.com is rated</seller-ratings-advertiser-info>
<seller-ratings-rating>4.5</seller-ratings-rating>
<seller-ratings-review-count>1,215 reviews</seller-ratings-review-count>
<seller-ratings-source-url>
http://www.google.com/products/seller?zmi=blah1.com
</seller-ratings-source-url>
</result>

Does that make sense?

Thanks

Submitted by support on Sat, 2011-08-20 11:08

Hi Shawn,

Rather than parsing using

xml|SEARCH-RESULTS/COLLECTION/GROUP/GROUP/

...could you try instead using:

xml|SEARCH-RESULTS/COLLECTION/GROUP/RESULT/

As a basic test, you can use the print_r() method to show the output of each record using that Format String, e.g.

<?php
  header
("Content-Type: text/plain"); // makes print_r output easier to read
  
require("MagicParser.php");
  function 
myRecordHandler($record)
  {
    
print_r($record);exit();
  }
  
MagicParser_parse("filename.xml","myRecordHandler","xml|SEARCH-RESULTS/COLLECTION/GROUP/RESULT/");
?>

If you're not sure from the output displayed how to proceed, if you could perhaps email me a link to the XML source, or if it is small enough then attached (zipped if possible) and I'll take a look for you...

Cheers!
David.

Submitted by shawnwalters on Sat, 2011-08-20 13:32

Thanks, that worked for one "group" but didn't return any of the other data from the feed. I emailed you my zip file.

Submitted by support on Sun, 2011-08-21 07:39

Thanks Shawn, I'll follow up by email...