Reputation: 15
When trying to access the simplexmlelement with PHP (second below). I use the following code $candidate->result->recorddetail->FL[0]
and expect to be returned 2972941000000380012, but reach the (first below). I just need to reach this data = 2972941000000380012; Thank you
edit: when I access the FL array it doesn't just return the position i want.
SimpleXMLElement {#360
+"@attributes": array:1 [
"val" => "Id"
]
+0: "2972941000000380012"
}
when I return the string about, instead of reaching the destination I am received the second code block;
SimpleXMLElement {#357
+"@attributes": array:1 [
"uri" => "/crm/private/xml/Contacts/insertRecords"
]
+"result": SimpleXMLElement {#352
+"message": "Record(s) updated successfully"
+"recorddetail": SimpleXMLElement {#355
+"FL": array:5 [
0 => "2972941000000380012"
1 => "2018-01-17 14:39:17"
2 => "2018-01-17 15:11:49"
3 => SimpleXMLElement {#368
+"@attributes": array:1 [
"val" => "Created By"
]
}
4 => SimpleXMLElement {#369
+"@attributes": array:1 [
"val" => "Modified By"
]
}
]
}
}
}
Upvotes: 1
Views: 55
Reputation: 57131
When you use (for example)...
$x = $candidate->result->recorddetail->FL[0];
This assigns the SimpleXMLElement and not the element value, which is what you really want. You can fetch the value by casting this to a string, which will just return the elements content...
$x = (string)$candidate->result->recorddetail->FL[0];
Upvotes: 1