php - Trouble parsing the pubmed central API XML


I'm trying to parse the xml output of the PMC API, yet for some reason I get only errors or empty results.. (had no trouble parsing the Pubmed API..)

This is how the XML tools like :

  <article xmlns:mml="" article-type="research-article">
        <journal-id journal-id-type="nlm-ta">Cell Death Differ</journal-id>
        <journal-id journal-id-type="iso-abbrev">Cell Death Differ</journal-id>
          <journal-title>Cell Death and Differentiation</journal-title>
        <issn pub-type="ppub">1350-9047</issn>
        <issn pub-type="epub">1476-5403</issn>

And this is my code:

$xml = simplexml_load_file($query);
$journal_name = (string)$xml->{'pmc-articleset'}->article->front->{'journal-meta'}->{'journal-title-group'}->{'journal-title'};
echo "Title: ".$journal_name;

Any advice would be appreciated!




You are already in thearticle-set element when you start and$article is an element, not a variable, so the$ should be removed.

echo (string)$xml->article->front->{'journal-meta'}->{'journal-title-group'}->{'journal-title'};

People are also looking for solutions to the problem: php - how to get the count of the posts for each month in laravel


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.