PHP parse XML url using simpleXML












1















I am trying to parse a shoutcast XML url using PHP and simpleXML.



<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$url = 'http://api.shoutcast.com/legacy/stationsearch?k=mydeveloperAPIkey&search=fleetwood';
$stationlist = simplexml_load_file($url) or die("feed not loading");
echo "<pre>" . print_r($stationlist) . "</pre>";

echo $stationlist->station[0]->name . "name <br>";
echo $stationlist->station[0]->mt . "mt <br>";
echo $stationlist->station[0]->id . "id <br>";

?>


print_r shows me this: http://sahanaya.net/kusal/1.php



how do I access the station name, mt, id, genre, ct, lc and others please ? What am I doing wrong ?










share|improve this question

























  • Target URL return Invalid parameter error

    – Mohammad
    Nov 13 '18 at 8:00











  • Please can you edit your question to include an Minimal, Complete, and Verifiable example - in this case, a small XML document with the same structure as the one you are processing, and the output you get running your code with that document. Please also make sure you've read the basic examples in the PHP manual and searched for related questions here.

    – IMSoP
    Nov 13 '18 at 9:38











  • @IMSoP thank you so much for the advice and guidance. While doing what you had asked I actually managed to solve my problem. What do I do now ? Delete the question ? Or answer my own question ?

    – Aruna Hewapathirane
    Nov 14 '18 at 2:08











  • I'm glad you figured it out. You are welcome to answer your own question if you think it will help other people in future; if so, make sure the question is clear enough that people are likely to find it. If you don't think it would be useful to future readers, deleting the question is also an option.

    – IMSoP
    Nov 14 '18 at 9:41
















1















I am trying to parse a shoutcast XML url using PHP and simpleXML.



<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$url = 'http://api.shoutcast.com/legacy/stationsearch?k=mydeveloperAPIkey&search=fleetwood';
$stationlist = simplexml_load_file($url) or die("feed not loading");
echo "<pre>" . print_r($stationlist) . "</pre>";

echo $stationlist->station[0]->name . "name <br>";
echo $stationlist->station[0]->mt . "mt <br>";
echo $stationlist->station[0]->id . "id <br>";

?>


print_r shows me this: http://sahanaya.net/kusal/1.php



how do I access the station name, mt, id, genre, ct, lc and others please ? What am I doing wrong ?










share|improve this question

























  • Target URL return Invalid parameter error

    – Mohammad
    Nov 13 '18 at 8:00











  • Please can you edit your question to include an Minimal, Complete, and Verifiable example - in this case, a small XML document with the same structure as the one you are processing, and the output you get running your code with that document. Please also make sure you've read the basic examples in the PHP manual and searched for related questions here.

    – IMSoP
    Nov 13 '18 at 9:38











  • @IMSoP thank you so much for the advice and guidance. While doing what you had asked I actually managed to solve my problem. What do I do now ? Delete the question ? Or answer my own question ?

    – Aruna Hewapathirane
    Nov 14 '18 at 2:08











  • I'm glad you figured it out. You are welcome to answer your own question if you think it will help other people in future; if so, make sure the question is clear enough that people are likely to find it. If you don't think it would be useful to future readers, deleting the question is also an option.

    – IMSoP
    Nov 14 '18 at 9:41














1












1








1








I am trying to parse a shoutcast XML url using PHP and simpleXML.



<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$url = 'http://api.shoutcast.com/legacy/stationsearch?k=mydeveloperAPIkey&search=fleetwood';
$stationlist = simplexml_load_file($url) or die("feed not loading");
echo "<pre>" . print_r($stationlist) . "</pre>";

echo $stationlist->station[0]->name . "name <br>";
echo $stationlist->station[0]->mt . "mt <br>";
echo $stationlist->station[0]->id . "id <br>";

?>


print_r shows me this: http://sahanaya.net/kusal/1.php



how do I access the station name, mt, id, genre, ct, lc and others please ? What am I doing wrong ?










share|improve this question
















I am trying to parse a shoutcast XML url using PHP and simpleXML.



<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$url = 'http://api.shoutcast.com/legacy/stationsearch?k=mydeveloperAPIkey&search=fleetwood';
$stationlist = simplexml_load_file($url) or die("feed not loading");
echo "<pre>" . print_r($stationlist) . "</pre>";

echo $stationlist->station[0]->name . "name <br>";
echo $stationlist->station[0]->mt . "mt <br>";
echo $stationlist->station[0]->id . "id <br>";

?>


print_r shows me this: http://sahanaya.net/kusal/1.php



how do I access the station name, mt, id, genre, ct, lc and others please ? What am I doing wrong ?







php xml simplexml






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 1:35







Aruna Hewapathirane

















asked Nov 13 '18 at 1:15









Aruna HewapathiraneAruna Hewapathirane

4319




4319













  • Target URL return Invalid parameter error

    – Mohammad
    Nov 13 '18 at 8:00











  • Please can you edit your question to include an Minimal, Complete, and Verifiable example - in this case, a small XML document with the same structure as the one you are processing, and the output you get running your code with that document. Please also make sure you've read the basic examples in the PHP manual and searched for related questions here.

    – IMSoP
    Nov 13 '18 at 9:38











  • @IMSoP thank you so much for the advice and guidance. While doing what you had asked I actually managed to solve my problem. What do I do now ? Delete the question ? Or answer my own question ?

    – Aruna Hewapathirane
    Nov 14 '18 at 2:08











  • I'm glad you figured it out. You are welcome to answer your own question if you think it will help other people in future; if so, make sure the question is clear enough that people are likely to find it. If you don't think it would be useful to future readers, deleting the question is also an option.

    – IMSoP
    Nov 14 '18 at 9:41



















  • Target URL return Invalid parameter error

    – Mohammad
    Nov 13 '18 at 8:00











  • Please can you edit your question to include an Minimal, Complete, and Verifiable example - in this case, a small XML document with the same structure as the one you are processing, and the output you get running your code with that document. Please also make sure you've read the basic examples in the PHP manual and searched for related questions here.

    – IMSoP
    Nov 13 '18 at 9:38











  • @IMSoP thank you so much for the advice and guidance. While doing what you had asked I actually managed to solve my problem. What do I do now ? Delete the question ? Or answer my own question ?

    – Aruna Hewapathirane
    Nov 14 '18 at 2:08











  • I'm glad you figured it out. You are welcome to answer your own question if you think it will help other people in future; if so, make sure the question is clear enough that people are likely to find it. If you don't think it would be useful to future readers, deleting the question is also an option.

    – IMSoP
    Nov 14 '18 at 9:41

















Target URL return Invalid parameter error

– Mohammad
Nov 13 '18 at 8:00





Target URL return Invalid parameter error

– Mohammad
Nov 13 '18 at 8:00













Please can you edit your question to include an Minimal, Complete, and Verifiable example - in this case, a small XML document with the same structure as the one you are processing, and the output you get running your code with that document. Please also make sure you've read the basic examples in the PHP manual and searched for related questions here.

– IMSoP
Nov 13 '18 at 9:38





Please can you edit your question to include an Minimal, Complete, and Verifiable example - in this case, a small XML document with the same structure as the one you are processing, and the output you get running your code with that document. Please also make sure you've read the basic examples in the PHP manual and searched for related questions here.

– IMSoP
Nov 13 '18 at 9:38













@IMSoP thank you so much for the advice and guidance. While doing what you had asked I actually managed to solve my problem. What do I do now ? Delete the question ? Or answer my own question ?

– Aruna Hewapathirane
Nov 14 '18 at 2:08





@IMSoP thank you so much for the advice and guidance. While doing what you had asked I actually managed to solve my problem. What do I do now ? Delete the question ? Or answer my own question ?

– Aruna Hewapathirane
Nov 14 '18 at 2:08













I'm glad you figured it out. You are welcome to answer your own question if you think it will help other people in future; if so, make sure the question is clear enough that people are likely to find it. If you don't think it would be useful to future readers, deleting the question is also an option.

– IMSoP
Nov 14 '18 at 9:41





I'm glad you figured it out. You are welcome to answer your own question if you think it will help other people in future; if so, make sure the question is clear enough that people are likely to find it. If you don't think it would be useful to future readers, deleting the question is also an option.

– IMSoP
Nov 14 '18 at 9:41












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53272367%2fphp-parse-xml-url-using-simplexml%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53272367%2fphp-parse-xml-url-using-simplexml%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Full-time equivalent

Bicuculline

さくらももこ