Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用相同的simplexmlobject文件获取不同的输出。。。?_Php_Arrays_Attributes_Simplexml - Fatal编程技术网

Php 使用相同的simplexmlobject文件获取不同的输出。。。?

Php 使用相同的simplexmlobject文件获取不同的输出。。。?,php,arrays,attributes,simplexml,Php,Arrays,Attributes,Simplexml,对不起,我忘了检查$MeshHeading->QualifierName。。。现在我做到了。。。但我还是得到了错误 如果获得此simpleXMLobject: [MeshHeading] => Array ( [0] => SimpleXMLElement Object

对不起,我忘了检查$MeshHeading->QualifierName。。。现在我做到了。。。但我还是得到了错误

如果获得此simpleXMLobject:

[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
                                                )
如果我输入以下代码:

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 "</pre>";
   }
  }
 else
  {
  echo "mesheading is missing in article " . $i . "<br />";
  $l++;
  }
致意
Thijs

我认为这就是问题所在:

if($mesheading->QualifierName);
________________________________^限定符(名称)
{
...
}
/*更好*/
if(isset($MeshHeading->QualifierName))
{
...
}

我认为这就是问题所在:

if($mesheading->QualifierName);
________________________________^限定符(名称)
{
...
}
/*更好*/
if(isset($MeshHeading->QualifierName))
{
...
}
if(isset($MeshHeading->QualifierName)){/…}if(isset($MeshHeading->QualifierName)){/…}
[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

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

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

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