This is a difficult question...:
CHANGE !!
I tried this ...:
But this does not work ...:
if ($citation->MeshHeadingList)
{
foreach ($citation->MeshHeadingList->MeshHeading as $mesh_heading)
{
$mesh_tag = $mesh_heading->DescriptorName;
if (isset($mesh_heading->QualifierName))
{
if (!array_key_exists($mesh_tag, $mesh_tags_array))
{
$mesh_tags_array[$mesh_tag][] = 0;
foreach ($mesh_heading->QualifierName as $qualifier_name)
{
if (!array_key_exists($qualifier_name, $mesh_tags_array)
{
$mesh_tags_array[][$qualifiername] = 0;
}
else
{
$mesh_tags_array[][$qualifiername] += 1;
}
}
if ($mesh_heading->DescriptorName->attributes() == "Y")
{
$major = 3;
}
else
{
$major = 0;
}
$mesh_tags_array[$mesh_tag][] += $position_rank + $date_rank + $major;
}
else
{
if ($mesh_heading->DescriptorName->attributes() == "Y")
{
$major = 3;
}
else
{
$major = 0;
}
if (!array_key_exists($mesh_tag, $mesh_tags_array))
{
$mesh_tags_array[$mesh_tag][] = 0;
}
else
{
$mesh_tags_array[$mesh_tag][] += $position_rank + $date_rank + $major;
}
}
}
}
}
else
{
echo "mesheading is missing in article " . $i . "<br />";
}
And here is xmlobject:
[MeshHeadingList] => SimpleXMLElement Object
(
[MeshHeading] => Array
(
[0] => SimpleXMLElement Object
(
[DescriptorName] => Acoustic Stimulation
[QualifierName] => methods
)
[1] => SimpleXMLElement Object
(
[DescriptorName] => Adult
)
[2] => SimpleXMLElement Object
(
[DescriptorName] => Auditory Perception
[QualifierName] => physiology
)
[3] => SimpleXMLElement Object
(
[DescriptorName] => Electroencephalography
[QualifierName] => methods
)
[4] => SimpleXMLElement Object
(
[DescriptorName] => Event-Related Potentials, P300
[QualifierName] => Array
(
[0] => genetics
[1] => physiology
)
)
[5] => SimpleXMLElement Object
(
[DescriptorName] => Schizotypal Personality Disorder
[QualifierName] => Array
(
[0] => diagnosis
[1] => genetics
[2] => psychology
[3] => clinical physiology
)
)
[MeshHeading] => Array
(
[0] => SimpleXMLElement Object
(
[DescriptorName] => Adolescent
)
[1] => SimpleXMLElement Object
(
[DescriptorName] => Event-Related Potentials, P300
[QualifierName] => Array
(
[0] => genetics
[1] => physiology
[2] => methods
)
)
[2] => SimpleXMLElement Object
(
[DescriptorName] => Attention
)
[3] => SimpleXMLElement Object
(
[DescriptorName] => Female
)
[4] => SimpleXMLElement Object
(
[DescriptorName] => Genetic Predisposition to Disease
[QualifierName] => Array
(
[0] => genetics
[1] => psychology
)
)
[5] => SimpleXMLElement Object
(
[DescriptorName] => Schizotypal Personality Disorder
[QualifierName] => Array
(
[0] => diagnosis
[1] => genetics
[2] => psychology
)
)
I want to output it in the following array:
Acoustic Stimulation (1)
-methods (1)
Adult (1)
Auditory Perception (1)
-physiology (1)
Electroencephalography (1)
-methods (1)
Event-Related Potentials, P300 (2)
-genetics (2)
-physiology (2)
-methods (1)
Schizotypal Personality Disorder (2)
-diagnosis (2)
-genetics (2)
-psychology (2)
-clinical physiology (1)
Adolescent (1)
Attention (1)
Female (1)
Genetic Predisposition to Disease (1)
-genetics (1)
-psychology (1)
Explanion: If the descriptor name exists, it adds the value of one; if the QualifierName name exists in the same Name descriptor, it also adds the value to the QualifierName ...
As you can see, it should be checked in the first "array_key_exists" and then in the array in the array ...?
I worked with a one-dimensional array, but it is much more complicated ... ??
Regards, Tice
Thijs source
share