xmlwriter - Rewrite existing attribute value from Xml String? -


is possible rewrite existing attribute xml string?

if have:

$xml_str = "<root>     <nodea attr1="value1"></nodea> </root>";  //rewrite $xml_str 

how can find nodea , @ same time rewrite value1?

// save xml string physical path file_put_contents($xml_save_path.ds.$xml_filename, $xml_str); 

you can use simplexml parse xml in php.

here's simplified version value1 , replace value2 echo new xml.

$xml_str = "<root>     <nodea attr1='value1'></nodea> </root>";  $doc = simplexml_load_string($xml_str);  $doc->nodea['attr1'] = 'value2';  echo $doc->asxml(); 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -