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))
    {
      ...
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘