php - Why is a curly brace around a string not outputting the correct SimpleXML result? -
i getting info api returns list of tasks so:
<tasks> <task> <id type="integer">937510</id> <external-id nil="true"> <description>needs italic in 2nd line of re-create in paragraph</description> </external-id> </task> </tasks>
i attempting parse above xml using simple php code in 5.6.2. $api
object of defined class retrieves info without issue:
$tasks_xml = $api->get_project_tasks('17347'); $tasks_object = new simplexmlelement($tasks_xml); echo '<h2>'.$tasks_object->task[0]->id.'</h2>'; echo '<h2>'.$tasks_object->task[0]->{'external-id'}->description.'</h2>';
however, output receive following. external-id
not accessed though surrounding in curly braces , quotes.
<h2>280095</h2> <h2></h2>
i same result if save 'external-id'
variable $external_id
, access using ->task[0]->$external_id
.
what need access info within external-id
node?
edit: turns out when simplexml parsed xml, made description
kid of external-id
. updating query task[0]->description
solved problem. thanks, mario.
php xml oop simplexml curly-braces
No comments:
Post a Comment