Call attributes()
and then access them as properties.
$node->attributes()->Desc
Pregunta
I have this object returned:
Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Desc] => Amount should be numeric.
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Desc] => Please enter your Reference Number.
)
)
)
How can I get the desc values? I need to get both Desc Values('Amount should be numeric.' and 'Please enter your Reference Number. ')
I have tried:
$res = $str[0];
it returned:
SimpleXMLElement Object
(
[@attributes] => Array
(
[Desc] => Amount should be numeric.
)
)
Solución 2
Call attributes()
and then access them as properties.
$node->attributes()->Desc
Otros consejos
Your object is a SimpleXML object.
You can learn how to use it here:
http://php.net/manual/fr/book.simplexml.php
To solve your issue, you can use this:
$res0 = $str[0]->attributes()->Desc;
$res1 = $str[1]->attributes()->Desc;