Jump to content

XML Question


dennismonsewicz

Recommended Posts

Is there anyway to overwrite a value in an XML document?

 

<?xml version="1.0"?>
<files>
<create>
	<name>coxdeductible.create.csv</name>
</create>
<insert>
	<name>coxdeductible.insert.csv</name>
</insert>
<check>
	<installed>no</installed>
</check>
</files>

 

I want to rewrite the check value to be yes in my php program

Link to comment
https://forums.phpfreaks.com/topic/195848-xml-question/
Share on other sites

You'd use the SimpleXML library that PHP should be installed with:

<?php
$xml = new SimpleXMLElement($xmlstring);
$xml->files->create[2]->check->installed = yes;

 

Don't quote me on the code, but you can easily manipulate XML with the extension:

http://www.php.net/manual/en/simplexml.examples-basic.php

Link to comment
https://forums.phpfreaks.com/topic/195848-xml-question/#findComment-1028750
Share on other sites

You'd use the SimpleXML library that PHP should be installed with:

<?php
$xml = new SimpleXMLElement($xmlstring);
$xml->files->create[2]->check->installed = yes;

 

Hmmm I am using simplexml_load_string... how could I incorporate your example with that functionality?

 

Don't quote me on the code, but you can easily manipulate XML with the extension:

http://www.php.net/manual/en/simplexml.examples-basic.php

Link to comment
https://forums.phpfreaks.com/topic/195848-xml-question/#findComment-1028764
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.