I'm trying to parse complex multilevel XML in PHP. Part of the XML looks like this:
<records>
<record>
<title language="eng">Barcode Technology Acceptance and Utilization in Health Information Management Department at Academic Hospitals According to Technology Acceptance Model</title>
<authors>
<author>
<name>Asghar Ehteshami</name>
<email>-</email>
<affiliationId>1</affiliationId>
</author>
</authors>
<keywords language="eng">
<keyword>Barcode</keyword>
<keyword>Technology Acceptance Model</keyword>
<keyword>Health Information Technology</keyword>
</keywords>
</record>
<record>
<title language="eng">Cardiac Structural and Functional Changes Evaluated by Transthoracic and Tissue Doppler Echocardiography in Adult Patients with Sickle Cell Disease</title>
<authors>
<author>
<name>Mojdeh Dabirian</name>
<email>-</email>
<affiliationId>1</affiliationId>
</author>
<author>
<name>Ghasem Janbabaei</name>
<email>-</email>
<affiliationId>2</affiliationId>
</author>
<author>
<name>Hossein Karami</name>
<email>-</email>
<affiliationId>3</affiliationId>
</author>
<author>
<name>Maryam Nabati</name>
<email>-</email>
<affiliationId>4</affiliationId>
</author>
<author>
<name>Mohsen Aarabi</name>
<email>-</email>
<affiliationId>5</affiliationId>
</author>
<author>
<name>Morteza Namazi</name>
<email>-</email>
<affiliationId>6</affiliationId>
</author>
<author>
<name>Hadi Darvishi-Khezri</name>
<email>-</email>
<affiliationId>7</affiliationId>
</author>
</authors>
<keywords language="eng">
<keyword>Ventricular structure</keyword>
<keyword>Ventricular function</keyword>
<keyword>Transthoracic echocardiography</keyword>
<keyword>Sickle cell disease</keyword>
<keyword>Tissue Doppler echocardiography</keyword>
</keywords>
</record>
<record>
...
I want to have it parse like this:
Title 1
Author name1, Author name2...
Title 2
Author name1, Author name2...
...
No matter what, I always get only first name of the author even in the records with multiple author names, like in record number 2 in XML example.
Thanks!
Adding my code:
$xml=simplexml_load_file("feed_doaj-v25-i1.000.xml") or die("Error: Cannot create object");
foreach($xml as $article) {
$title = $article->title;
$name = $article->authors->author->name;
echo '<h4>'.$title.'</h4>';
echo '<p>'.$name.'</p><br/>';
?>
In my example I got from XML following:
Barcode Technology Acceptance and Utilization in Health Information Management Department at Academic Hospitals According to Technology Acceptance Model
Asghar Ehteshami
Cardiac Structural and Functional Changes Evaluated by Transthoracic and Tissue Doppler Echocardiography in Adult Patients with Sickle Cell Disease
Mojdeh Dabirian
So, problem is, in second title, my code pulls only first name author name from XML even if there are 7 names for that article.
Hope I clear a bit my problem :)