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 8542987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:11:51+00:00 2026-06-11T12:11:51+00:00

Looked at a few other SO posts on this but no joy. I’ve got

  • 0

Looked at a few other SO posts on this but no joy.

I’ve got this code:

$url = "http://itunes.apple.com/us/rss/toppaidapplications/limit=10/genre=6014/xml";
$string = file_get_contents($url);
$string = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $string);
$xml = simplexml_load_string($string);

foreach ($xml->entry as $val) {
    echo "RESULTS: " . $val->attributes() . "\n";

but I can’t get any results.
I’m specifically interested in getting the ID value which would be 549592189 in this fragment:

<id im:id="549592189" im:bundleId="com.activision.wipeout">http://itunes.apple.com/us/app/wipeout/id549592189?mt=8&amp;uo=2</id>

Any suggestions?

  • 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-11T12:11:52+00:00Added an answer on June 11, 2026 at 12:11 pm

    SimpleXML gives you can easy way to drill down in the XML structure and get the element(s) you want. No need for the regex, whatever it does.

    <?php
    
    // Load XML
    $url = "http://itunes.apple.com/us/rss/toppaidapplications/limit=10/genre=6014/xml";
    $string = file_get_contents($url);
    $xml = new SimpleXMLElement($string);
    
    // Get the entries
    $entries = $xml->entry;
    
    foreach($entries as $e){
        // Get each entriy's id
        $id = $e->id;
        // Get the attributes
        // ID is in the "im" namespace
        $attr = $id->attributes('im', TRUE);
        // echo id
        echo $attr['id'].'<br/>';
    }
    

    DEMO: http://codepad.viper-7.com/qNo7gs

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've looked at a few posts here like this but this doesn't seem to
EDIT: I got this working now. I have updated the code: I've looked at
I've looked at a few other try catch finally questions on here but I'm
I know how the seek works generally, and have looked at few other posts.
I've looked at other JLabel threads and though similar, a few just don't seem
I've looked at a few examples, but they were all written when the project
A few months ago when I looked into HTTP-live streaming I thought I found
I have looked at Spring MVC a few times briefly, and got the basic
I looked at a few other questions regarding a similar issue, and I figured
First of all: I looked through other posts on stackoverflow and none of them

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.