So here is my code:
foreach($this->simpleXMLobject->path->toRecord->myRecord as $record)
{
$childXML = new \CurlClass\GetXML($record->link, $this->timeout);
$result = $childXML->get();
$xml = simplexml_load_string($result, NULL, LIBXML_NOCDATA);
if($xml !== FALSE)
{
$record->newChild = $xml->newChaldData;
}
}
As you can see i need to add Object to every $this->simpleXMLobject->path->toRecord->myRecord
record.
And its not working!
In a print_r()
of the final result i'm getting this:
[n] => SimpleXMLElement Object
(
[firstname] => ANGELA
[lastname] => LEE
[dob] => SimpleXMLElement Object
(
)
[id] => 67404998
[newChild] => SimpleXMLElement Object
(
[0] =>
)
)
I know that i have the XML in a $result
.
Any ideas?
UPDATE:
The XMLs:
<xml>
<result>
<stats/>
<somadata/>
<somadata/>
<somadata/>
<crimeData>
<person>
<fName>Eric</fName>
<lName>Eric</lName>
<caseDetailed>data1</caseDetailes>
</person>
...
<person>
<fName>Eric</fName>
<lName>Eric</lName>
<caseDetailes>https://urltocasedetailes.com/blha/nlha</caseDetailes>
</person>
</crimeData>
</result>
https://urltocasedetailes.com/blha/nlha
returns this kind of data:
<xml>
<result>
<stats/>
<detailesPart1>
<data1>Eric</data1>
<data2>Eric</data2>
</detailesPart1>
<detailesPart2>
<data1>Eric</data1>
<data2>Eric</data2>
</person>
</crimeData>
</result>
The idea is to get data from 'https://urltocasedetailes.com/blha/nlha' as xml object and add to the original xml <person>
records
UPDATE
If i replace this:
if($xml !== FALSE)
{
$record->newChild = $xml->newChaldData;
}
With this:
if($xml !== FALSE)
{
$record->newChild = $xml->newChaldData->child1;
}
It works! But that's not really what i need.