I'm trying the following without success. Anyone who can help me out about why the attribute imageId is not changed?
$dom = new DOMDocument;
$dom->loadXML($appCom_file_name);
$frames = $dom->getElementsByTagName('frame');
foreach ($frames as $frame) {
if ($frame->getAttribute('imageId') == '') {
$frame->setAttribute('imageId', $id);
}
}
$dom->saveXML();
XML source:
<template>
<appCom>
<page>
<defaultValues>
<frame id="frame_01_0" deltaRotation="0" deltaScale="100" deltaX="0" deltaY="0" imageId="" />
<frame id="frame_02_0" deltaRotation="0" deltaScale="100" deltaX="0" deltaY="0" imageId="" />
<frame id="frame_03_0" deltaRotation="0" deltaScale="100" deltaX="0" deltaY="0" imageId="" />
</defaultValues>
</page>
<page>
<defaultValues>
<frame id="frame_01_1" deltaRotation="0" deltaScale="100" deltaX="0" deltaY="0" imageId="" />
<frame id="frame_02_1" deltaRotation="0" deltaScale="100" deltaX="0" deltaY="0" imageId="" />
<frame id="frame_03_1" deltaRotation="0" deltaScale="100" deltaX="0" deltaY="0" imageId="" />
</defaultValues>
</page>
</appCom>
</template>
Thanks for all feeback!
It should not output anything but save the file again. ID was of course defined but I forgot to include it with my question. This works now: