PHP get values from SimpleXMLElement array

前端 未结 4 1745
天命终不由人
天命终不由人 2020-11-29 10:48

I have this:

  [1]=>
object(SimpleXMLElement)#6 (1) {
  [\"@attributes\"]=>
  array(14) {
    [\"name\"]=>
    string(5) \"MySQL\"
    [\"acknowledg         


        
4条回答
  •  有刺的猬
    2020-11-29 11:32

    With SimpleXML, you can get :

    • sub-elements, using object notation : $element->subElement
    • and attributes, using array notation : $element['attribute']


    So, here, I'd say you'd have to use :

    echo $child['name'];
    


    As a reference, and for a couple of examples, see the Basic usage section of simplexml's manual.

    Example #6 should be the interesting one, about attributes.

提交回复
热议问题