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
https://forums.phpfreaks.com/topic/212271-trouble-with-getxmltree/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.