<Alert>
name = 'mmm'
hope='kk'
<test>
Name = 'kkm'
</test>
</Alert>
$str="test";
$fileName="test-fileName";
$xml = simplexml_load_file(sampleXml);
(String) $xml->Alert->attribute()->hope=$str;
$xml->saveXML($fileName);
I can get elements, but I can't rewrite them...
Don't you know a good way?
Permission permissions can be written and read.
php xml
XML does not look good, but if you want to rewrite the hop value in this format, you need to get the text of Alert, replace the string, or parse the key value format separately.
If you want to rewrite it a little more XML-like, for example, you can rewrite hop with the following code:
<?php
$str = 'test';
$fileName='./new.xml';
$xml = simplexml_load_file('./sample.xml');
(String) $xml->alert->attributes()->hope=$str;
$xml->saveXML($fileName);
?>
<?xml version="1.0"?>
<root>
<alert hop="kk">
</alert>
</root>
© 2024 OneMinuteCode. All rights reserved.