0

I need to parse the following XML file below:

https://www.performanceexchange.com/publisher/report/api/17adeb41da1343209a32e6790ee1a286/xml/report/stats?startDate=2012-07-01&endDate=2012-08-13

$xml = simplexml_load_file( urlencode($mediatrust_url) );

Which outputs:

SimpleXMLElement Object
(
    [@attributes] => Array
    (
        [name] => StatsReport
    )

)

So it seems that it just picks up the name of the first tag.

2
  • 3
    you don't need to urlencode(). That url is also not outputting valid XML, so no surprise you're not getting much. Commented Aug 14, 2012 at 17:15
  • 4
    I see no XML at the given link. Commented Aug 14, 2012 at 17:18

1 Answer 1

3

Try this:

foreach($xml->attributes() as $k => $v)
{
    if($k == "name")
    {
        //do something
    }
}

Also, try using loading the XML string like this:

$sxml = simplexml_load_string(@file_get_contents($url));
Sign up to request clarification or add additional context in comments.

2 Comments

ok got rid of the urlencode, the XML url is performanceexchange.com/publisher/report/api/…
You need to fetch the namespaces first. This should help: stackoverflow.com/questions/5801089/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.