2014-10-28 09:58



I have written an xml-parser to read an XML-file. The XML-file is not mine so I can't change the structure. Things work great till I got to this special point. I want to read a value but I don't have a key to access this value. I marked the values (in red) in the screenshot below which I want to access.

enter image description here

When I dump the parent element (the PRAT->VALUE) I get this in return:

object(SimpleXMLElement)#31 (3) { ["@attributes"]=> array(5) { ["nr"]=> string(1) "1" ["unit"]=> string(3) "bar" ["unit_id"]=> string(4) "3103" ["vo"]=> string(0) "" ["vo_id"]=> string(0) "" } [0]=> string(2) "20" [1]=> string(1) "2" } 

As seen, at the end of the dump the values that I want to access are presented. I tried to access it like an array but that doesn't work. The values are not part of the attributes.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dongxiangxie8181 dongxiangxie8181 7年前

    use (String) keyword in front of it.


    echo (String) PRAT->VALUE;
    点赞 评论 复制链接分享