Получить другой вывод с тем же файлом simplexmlobject ...? - PullRequest
1 голос
/ 20 декабря 2010

Извините, я забыл поставить проверку для $ MeshHeading-> QualifierName ... сейчас я сделал ... но я все еще получаю ошибку ...?

Если получил этот простойXMLobject:

[MeshHeading] => Array
                                        (
                                            [0] => SimpleXMLElement Object
                                                (
                                                    [DescriptorName] => Acoustic Stimulationment Object
                                                    [QualifierName] => methods
                                                )

                                            [1] => SimpleXMLElement Object
                                                (
                                                    [DescriptorName] => Adolescent
                                                )

                                            [2] => SimpleXMLElement Object
                                                (
                                                    [DescriptorName] => Age Factors
                                                )

                                            [3] => SimpleXMLElement Object
                                                (
                                                    [DescriptorName] => Child
                                                )

                                            [4] => SimpleXMLElement Object
                                                (
                                                    [DescriptorName] => Electromyography
                                                    [QualifierName] => methods
                                                )

                                            [5] => SimpleXMLElement Object
                                                (
                                                    [DescriptorName] => Female
                                                )

                                            [6] => SimpleXMLElement Object
                                                (
                                                    [DescriptorName] => Galvanic Skin Response
                                                    [QualifierName] => physiology
                                                )

                                            [7] => SimpleXMLElement Object
                                                (
                                                    [DescriptorName] => Humans
                                                )

                                            [8] => SimpleXMLElement Object
                                                (
                                                    [DescriptorName] => Male
                                                )

                                            [9] => SimpleXMLElement Object
                                                (
                                                    [DescriptorName] => Muscle, Skeletal
                                                    [QualifierName] => physiology
                                                )

                                            [10] => SimpleXMLElement Object
                                                (
                                                    [DescriptorName] => Probability
                                                )

                                            [11] => SimpleXMLElement Object
                                                (
                                                    [DescriptorName] => Reaction Time
                                                    [QualifierName] => physiology
                                                )

                                            [12] => SimpleXMLElement Object
                                                (
                                                    [DescriptorName] => Sex Factors
                                                )

                                            [13] => SimpleXMLElement Object
                                                (
                                                    [DescriptorName] => Startle Reaction
                                                    [QualifierName] => physiology
                                                )

Если я введу этот код:

<code>if ($Citation->MeshHeadingList)
  {
   foreach ($Citation->MeshHeadingList->MeshHeading as $MeshHeading)
   {

   echo "<pre>";
   echo "[" .$MeshHeading->DescriptorName . "] ";
   echo "[" .$MeshHeading->DescriptorName->attributes() . "]";
   echo "<br /";

   if ($MeshHeading->QualifierName);
      {
  echo "[" .$MeshHeading->QualifierName . "] ";
  echo "[" .$MeshHeading->QualifierName->attributes() . "]";
  }


   echo "
";}} else {echo" в статье ". $ I. Отсутствует заголовок"."; $ l ++;}

Я понял ...?

[Acoustic Stimulation] [N]

[Adolescent] [N]


Warning:  main() [function.main]: Node no longer exists in /home/thijs/project/phptest/pubmed_fetch.php on line 119

[]

[Age Factors] [N]


Warning:  main() [function.main]: Node no longer exists in /home/thijs/project/phptest/pubmed_fetch.php on line 119

[]

[Child] [N]


Warning:  main() [function.main]: Node no longer exists in /home/thijs/project/phptest/pubmed_fetch.php on line 119

[]

[Electromyography] [N]

[Female] [N]


Warning:  main() [function.main]: Node no longer exists in /home/thijs/project/phptest/pubmed_fetch.php on line 119

[]

С уважением, Тийс

1 Ответ

1 голос
/ 21 декабря 2010

Я думаю, что это проблема:

if ($MeshHeading->QualifierName);
________________________________^ <-- remove semicolon 

if ($MeshHeading->QualifierName)
{
  ...
}

/* even better */
if (isset($MeshHeading->QualifierName))
{
  ...
}
...