1

I love SimpleXMLElement-- it's great as a XML Element Parser.So I am thinking is there an XML writer-- the one that changes the attribute values, for example, changing

<?xml version="1.0"?> <a b="One Two"> <c>Three Four</c> <d>Five Six</d> </a> 

to

<?xml version="1.0"?> <a b="One Two"> <c>seven</c> <d>eight</d> </a> 

Is there any existing library that does that? SimpleXMLElement doesn't provide that, I afraid.

Note that I am reading the XML from a file, not from a string.

2 Answers 2

3
$xml = '<?xml version="1.0"?> <a b="One Two"> <c>Three Four</c> <d>Five Six</d> </a>'; $xml = simplexml_load_string($xml); $xml->c = 'seven'; $xml->d = 'eight'; echo $xml->asXML(); 

Works!

Sign up to request clarification or add additional context in comments.

Comments

0

Keith Devens' PHP XML Library, version 1.2b

http://keithdevens.com/software/phpxml

It allows you to easily parse XML into a PHP data structure, and it allows you to serialize PHP data structures into XML.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.