For example I have file config.xml
in that file I have following xml content
<cruisecontrol>
<project name="Project" buildafterfailed="true">
<property name="QtDir" value="D:\QtSDK"/>
.
.
.
</project>
</cruisecontrol>
I need to be able to put value from php script
in this line
<property name="QtDir" value="New value"/>
Is there any way to do it without scanning this file like usual one? I mean how can I do it if I know that it is xml file, and I know that I need to change only this typies of lines.
Thank you on advance.
Try;
$xml = simplexml_load_string($yourXml); $property = $xml->addChild('property'); $property->addAttribute("name", "QtDir"); $property->addAttribute("value", "New Value"); echo $xml->asXML();