Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7599029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:33:30+00:00 2026-05-30T22:33:30+00:00

The Zend Service for Amazon does not provide BrowseNodes, so I decided to extend

  • 0

The Zend Service for Amazon does not provide BrowseNodes, so I decided to extend it. The Zend code can be found at http://framework.zend.com/manual/de/zend.service.amazon.html.

My code below works almost but Just Ancestors are not processed. I wonder if there is an error in the wsdl or the xpath. I am trying to debug, but or just processing Ancestors. BrowseNodeId, Name, IsCategoryRoot, Children are processed but Ancestors array is always empty. The xpath query is able to find Children, but not Ancestors.

Please find the Code below. And a part of the xml

Here is the anatomy of the wsdl for the XML extract of a ItemLookup
http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/AnatomyofaWSDL.html

The partial of xml response

<BrowseNodes>
    <BrowseNode>
        <BrowseNodeId>10605</BrowseNodeId>
        <Name>Education</Name>
        <Children>...</Children>
        <Ancestors>
            <BrowseNode>
                <BrowseNodeId>21</BrowseNodeId>
                <Name>Education & Reference</Name>
                <Ancestors>
                    <BrowseNode>
                        <BrowseNodeId>1000</BrowseNodeId>
                        <Name>Subjects</Name>
                        <IsCategoryRoot>1</IsCategoryRoot>
                        <Ancestors>
                            <BrowseNode>
                                <BrowseNodeId>283155</BrowseNodeId>
                                <Name>Books</Name>
                            </BrowseNode>
                        </Ancestors>
                    </BrowseNode>
                </Ancestors>
            </BrowseNode>
        </Ancestors>
    </BrowseNode>
</BrowseNodes>

How I am extending Zend_Service_Amazon_Item for BrowseNodes

class Zend_Service_Amazon_Item
{

    /**
     * @var array
     */
    public $BrowseNodes = array();

    public function __construct($dom) {

        // .... the code for the other items

        // .... for browsenode
        $result = $xpath->query('./az:BrowseNodes/*', $dom);
        if ($result->length > 1) {
            /**
             * @see Zend_Service_Amazon_BrowseNode
             */
            require_once 'Zend/Service/Amazon/BrowseNode.php';
            foreach ($result as $r) {
                $this->BrowseNodes[] = new Zend_Service_Amazon_BrowseNode($r);
            }
        }
    }
}

I have created a new Class for the BrowseNodes

class Zend_Service_Amazon_BrowseNode
{
    /**
     * @var integer
     */
    public $BrowseNodeId;

    /**
     * @var string
     */
    public $Name;

    /**
     * @var boolean
     */
    public $IsCategoryRoot;


    /**
     * @var array BrwoserNodes
     */
    public $Ancestors = array();

    /**
     * @var string
     */
    public $Children = array();

    /**
     * Assigns values to properties relevant to BrowseNode
     *
     * @param  DOMElement $dom
     * @return void
     */
    public function __construct(DOMElement $dom)
    {

        $xpath = new DOMXPath($dom->ownerDocument);
        $xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2011-08-01');
        foreach (array('BrowseNodeId', 'Name') as $el) {
            $result = $xpath->query("./az:$el/text()", $dom);
            if ($result->length == 1) {
                $this->$el = (string) $result->item(0)->data;
            }
        }

        $result = $xpath->query('./az:IsCategoryRoot/text()', $dom);
        if ($result->length == 1) {
            $this->IsCategoryRoot = (bool) $result->item(0)->data ;
        }

        foreach (array('Children','Ancestors') as $el) {
            $result = $xpath->query("./$el/*", $dom);
            if ($result->length > 1) {
                foreach ($result as $r) {
                    array_push($this->$el, new Zend_Service_Amazon_BrowseNode($r));
                }
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:33:32+00:00Added an answer on May 30, 2026 at 10:33 pm

    I’ve found the answer, hope it helps other’s too.

    There are two errors:

    1. I don’t know what az: stands for but it is needed. Instead of

          $result = $xpath->query("./$el/*", $dom);
      

      With “az:”

          $result = $xpath->query("./az:$el/*", $dom);
      
    2. I’ve been testing with only one Ancestor, so the argument in if is true, if I have a least two nodes in the result. According to the WSDL I could have Results with BrowseNodes, which have more than one Ancestor, but they must be rare or I was only looking for Items, which has only one Ancestor.

          if ($result->length > 1) {
      

      should be:

          if ($result->length > 0) {
      

    Once again the corrected code in last part of Zend_Service_Amazon_BrowseNode

        foreach (array('Children','Ancestors') as $el) {
            $result = $xpath->query("./az:$el/*", $dom);
            if ($result->length > 0) {
                foreach ($result as $r) {
                    array_push($this->$el, new Zend_Service_Amazon_BrowseNode($r));
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is it possible to stream a stream from Zend_Service_Amazon_S3 (http://framework.zend.com/manual/en/zend.service.amazon.s3.html#zend.service.amazon.s3.streaming) to the browser? I'm
I have read the examples here: http://framework.zend.com/manual/en/zend.gdata.spreadsheets.html But those examples assume the spreadsheet to
This article explains how to use Zend in Codeigniter. http://www.beyondcoding.com/2008/02/21/using-zend-framework-with-codeigniter/ I am using XAMPP
I am trying to seach/display books using Amazon Web Service with Zend Framework. The
I am trying to include the Zend_Service_Amazon_S3 file by using require_once 'Zend/Service/Amazon/S3.php'; I have
I'm trying to create a REST service in zend framework. I'm using zend server.
Zend Route issue. Normally it works fine. http://www.example.com/course-details/1/Physics-Newtons-Law But if I type in an
Examining Zend Framework, I found that all setter methods (of those I’ve examined) return
I've built a first-run web service on Zend Framework (1.10), and now I'm looking
I have some questions: Does Zend AMF has a service browser feature like AMFPHP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.