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

  • Home
  • SEARCH
  • 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 8201653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:53:28+00:00 2026-06-07T06:53:28+00:00

I am pulling out information using the ANN api. I used the simpleXML class

  • 0

I am pulling out information using the ANN api. I used the simpleXML class to get the information.

function explodeTest() {
            $result = $this->_restGenerator($this->ann, '6236');
            //print_r($result);
            foreach ($result->anime as $data) {
                print_r($data->info);
            } 
        }

_restGenerator function:

function _restGenerator($url,$q) {
        $url = $url . strtolower($q);
        if(strlen($q) > 0) {
            $q = file_get_contents($url);
            //$q = simplexml_load_file($url)
            return simplexml_load_string($q);
        }
    }

Constants:

$this->ann = 'http://cdn.animenewsnetwork.com/encyclopedia/api.xml?anime=';

When I run the function, I get this :

SimpleXMLElement Object ( [@attributes] => Array ( [gid] => 3506750509 [type] => Picture [src] => http://cdn.animenewsnetwork.com/thumbnails/fit200x200/encyc/A6236-259.jpg ) )

But the actual XML tag is displayed as this:

<anime id="6236" gid="1601610894" type="TV" name="Gintama" precision="TV" generated-on="2012-07-07T04:58:39Z">
   <info gid="3506750509" type="Picture" src="http://cdn.animenewsnetwork.com/thumbnails/fit200x200/encyc/A6236-259.jpg"/>
   <info gid="1229282479" type="Main title" lang="JA">Gintama</info>
   <info gid="556528412" type="Alternative title" lang="RU">Гинтама</info>
   <info gid="1383170257" type="Alternative title" lang="JA">銀魂</info>
   <info gid="380581077" type="Alternative title" lang="KO">은혼</info>
   <info gid="3483398015" type="Genres">action</info>
   <info gid="1567209986" type="Genres">adventure</info>
   <info gid="1221683927" type="Genres">comedy</info>
   <info gid="3139902810" type="Genres">drama</info>
   <info gid="2565080252" type="Genres">fantasy</info>
   <info gid="971885680" type="Genres">science fiction</info>
   <info gid="2312087995" type="Objectionable content">TA</info>
   <info gid="1950277303" type="Plot Summary">...</info>
   <info gid="2741727987" type="Running time">25</info>
   <info gid="3466023682" type="Number of episodes">201</info>
   <info gid="2618069239" type="Vintage">2006-04-04 to 2010-03-25</info>
   <info gid="820682777" type="Vintage">2007-12-04 (Italia, MTV Italia)</info>
   <info gid="2490517434" type="Vintage">2009-02-03 (Spain, Canal Extremadura)</info>
   <info gid="1770356394" type="Vintage">2009-08-30 (Malaysia, TV2)</info>
   <info gid="2362558760" type="Vintage">2010-01-18 (Philippines, ABS-CBN - Team Animazing)</info>
   <info gid="803932272" type="Vintage">2011-03-23 (Philippines - Hero, League of Heroes)</info>
   <info gid="2236361640" type="Vintage">2011-04-04</info>
   <info gid="1161326503" type="Opening Theme">#1: "Pray" by Tommy Heavenly6 (eps 1-24)</info>
   <info gid="2241431608" type="Opening Theme">#2: "Tooi Nioi" by YO-KING (eps 25-49)</info>
   <info gid="1855414862" type="Opening Theme">
#3: "Gin-iro no Sora" (銀色の空; "Silver Sky") by redballoon (eps 50-)
</info> ...

When i do print_r($result) … the info node is displayed as this

[info] => Array ( 
                    [0] => SimpleXMLElement Object ( 
                            [@attributes] => Array ( 
                                                [gid] => 3506750509 
                                                [type] => Picture 
                                                [src] => http://cdn.animenewsnetwork.com/thumbnails/fit200x200/encyc/A6236-259.jpg ) 
                                                ) 
                    [1] => Gintama 
                    [2] => Гинтама 
                    [3] => 銀魂 
                    [4] => ì€í˜¼ 
                    [5] => action 
                    [6] => adventure 
                    [7] => comedy 
                    [8] => drama 
                    [9] => fantasy 
                    [10] => science fiction 
                    [11] => TA 
                    [12] => Twenty years ago .. <synopsis>
                    [13] => 25 
                    [14] => 201 

I need to get the type attribute of the nodes to get the array to be distinguishable, or at least filter the info node by type attribute.

Thanks.

  • 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-06-07T06:53:29+00:00Added an answer on June 7, 2026 at 6:53 am

    Use the attributes function to get the attributes.

    foreach ($result->anime as $data) {
        foreach($data->info as $info){
            $a = $info->attributes();
            echo $a['type']. "\n";
        }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am pulling my hair out on this one... I am using the ASIHTTPRequest
I've been pulling out my hair trying to figure this problem out. I have
I have data in Excel files that I am pulling out using the MS
Using JavaScript I am pulling names out of webpage and stringing them together somehow
Pulling my hair out over this one. I have one wordpress install at /2009
I'm pulling my hair out here trying to get CSS to position only a
I've been pulling my hair out for the last few hours with this problem.
I am using Views 2 to get information from my Drupal 6 site. After
Sorry if this seems like an easy question, but I've started pulling hair out
I've been using this code to try and get data from the google weather

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.