i need value of custom_field "newtitle" (id 6) nested inside child "custom_fields" of following xml:
<issues total_count="63" offset="0" limit="100" type="array"> <issue> <id>65</id> <project id="7" name="projectname"/> <tracker id="7" name="trackername"/> <subject>mysubject</subject> ... <custom_fields type="array"> <custom_field id="4" name="ordertype"> <value>project</value> </custom_field> <custom_field id="26" name="extid"> <value>246558</value> </custom_field> <custom_field id="25" name="area" multiple="true"> <value type="array"> <value>process</value> <value>system</value> </value> </custom_field> <custom_field id="6" name="newtitle"> <value>abcdef</value> </custom_field> ... <custom_field id="20" name="kst"> <value/> </custom_field> <custom_field id="11" name="lkf"> <value>3</value> </custom_field> <custom_field id="17" name="link"> <value>xxx</value> </custom_field> </custom_fields> <created_on>2015-12-14t08:00:03z</created_on> <updated_on>2016-01-28t09:07:20z</updated_on> <closed_on/> </issue> </issues>
can tell me how php? managed display values of main fields. example subject:
foreach ($xml->issue $issue){ if((string) $issue->tracker['id'] == 7){ echo $issue->subject.'<br/>'; } }
use simplexml combined xpath:
$xml = simplexml_load_string($your_xml_here); $fields = $xml->xpath("//custom_field[@name='newtitle']"); foreach ($fields $field) { // sth. useful here }
Comments
Post a Comment