dp926460 2010-12-20 20:22
浏览 29
已采纳

使用相同的simplexml对象文件获取不同的输出...?

Sorry, i forgot to put a check for the $MeshHeading->QualifierName... now i did... but i still get the error...?

If got this 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 i put in this 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 "</pre>";
   }
  }
 else
  {
  echo "mesheading is missing in article " . $i . "<br />";
  $l++;
  }

I get this...?

[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

[]

Best regards Thijs

  • 写回答

1条回答 默认 最新

  • dthhlf1777 2010-12-21 01:03
    关注

    I think this is the problem :

    if ($MeshHeading->QualifierName);
    ________________________________^ <-- remove semicolon 
    
    if ($MeshHeading->QualifierName)
    {
      ...
    }
    
    /* even better */
    if (isset($MeshHeading->QualifierName))
    {
      ...
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址
  • ¥15 elmos524.33 eeprom的读写问题
  • ¥15 使用Java milo连接Kepserver服务端报错?
  • ¥15 用ADS设计一款的射频功率放大器
  • ¥15 怎么求交点连线的理论解?
  • ¥20 软件开发方法学习来了
  • ¥15 微信小程序商城如何实现多商户收款 平台分润抽成