i have an xml structure:
<root>
...
<B ID="444">
<C></C>
<D>Anything</D>
<E>
<child1 /*expected outcome came in here*/> /*sometimes here*/ </child1>
<child2>data2 <!-instead of here-></child2>
<child3>data3</child3>
<child4>data4 /* and also here instead*/</child4>
</E>
</B>
...
</root>
i made an xpath query to fetch //*B, where child2==data2 and child4==data4 like this:
$query = "//*[@ID=444]//*['data2' and 'data4']";
$result = $xml->xpath($query);
it worked fine. but now, i wanna update data1 and data3; after finding a match, using only simplexml API.
here's what i did, but not working rightly:
if(!empty($result)){
$result[0]['data2'] = "Blabla";
$result[0]['data4'] = "Blaaaaaaaa";
return $xml->saveXML($File;
}
what am i doing wrong ? or how is it better done with simplexml ? any idea will be apprciated.