Mam taki obiekt:
( [version] => 1.2 ) ( ( [source-language] => en [target-language] => pl [datatype] => plaintext ) [body] => SimpleXMLElement Object ( ( [0] => SimpleXMLElement Object ( ( [id] => note ) [source] => note [target] => UWAGA ) [1] => SimpleXMLElement Object ( ( [id] => tip ) [source] => tip [target] => PORADA ) [66] => SimpleXMLElement Object ( ( [id] => help.more_information ) [source] => help.more_information [target] => SimpleXMLElement Object ( ) ) ) ) )
i funkcję w php:
public function openFileWithTranslations(string $tagId) { $filePath = "../pl.xlf"; $objectFromXML = simplexml_load_file($filePath); $vel = 'trans-unit'; foreach ($objectFromXML->$vel as $msg) { return $msg['id']; } } }
Chciałbym aby po otwarciu funkcji openFileWithTranslations xml był parsowany:
1. note => zwróciłby mi wynik: Uwaga
2. tip => zwróciłby mi wynik: porada
itp.
Chciałbym otrzymywać w oparciu o podany klucz tagId wartość z parametru target.
Taki debug:
$objectFromXML = simplexml_load_file($filePath); $vel = 'trans-unit';
Pokazuje tylko SimpleXMLElement Object ( ) @1.
Z kolei taki:
SHow all object.
Może tu jest gdzieś problem?
Wie ktoś może jak to naprawić?