Jump to content

Trouble with GetXMLTree()


seanmt

Recommended Posts

I am trying to put the tree of an XML file into an array.

 

sample.xml

<?xml version='1.0' encoding='UTF-8'?>
<getHistogramsResponse xmlns="http://www.ebay.com/marketplace/search/v1/services">
  <ack>Success</ack>
  <version>1.7.0</version>
  <timestamp>2010-09-01T12:13:31.480Z</timestamp>
  <aspectHistogramContainer>
    <domainName>UK_CamerasPhoto_DigitalCameras_DigitalCameras_JN</domainName>
    <domainDisplayName>Digital Cameras</domainDisplayName>
    <aspect name="Brand">
      <valueHistogram valueName="Canon">
        <count>4323</count>
      </valueHistogram>
      <valueHistogram valueName="Sony">
        <count>2210</count>
      </valueHistogram>
    </aspect>
  </aspectHistogramContainer>
</getHistogramsResponse>

 

      $this->cXmlToArray->m_arr = GetXMLTree('sample.xml')

      if (isset($this->cXmlToArray->m_arr['getHistogramsResponse']['aspectHistogramContainer'][0]))
      {
        $this->m_arrResult = $this->cXmlToArray->m_arr['getHistogramsResponse']['aspectHistogramContainer'];
      }
      else if (count($this->cXmlToArray->m_arr['getHistogramsResponse']['aspectHistogramContainer']) > 0)
      {
        $this->m_arrResult[] = $this->cXmlToArray->m_arr['getHistogramsResponse']['aspectHistogramContainer'];
      }

 

However my output is showing as:

 

Array
(
    [0] => Array
        (
            [domainName] => UK_CamerasPhoto_DigitalCameras_DigitalCameras_JN
            [domainDisplayName] => Digital Cameras
            [aspect] => Array
                (
                    [0] => Array
                        (
                            [valueHistogram] => Array
                                (
                                    [0] => Array
                                        (
                                            [count] => 4311
                                        )

                                    [1] => Array
                                        (
                                            [count] => 2209
                                        )
                )
        )
)

 

So how do I get it to return the attributes name and valueName? Any help will be greatly appreciated.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.