It may be simple, but I could not find a single example on the Internet. I need to find node using xpath and replace it.
This is a small version of an xml document:
<?xml version="1.0" encoding="utf-16" standalone="yes"?> <w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"> <w:body> </w:p> <w:r> <w:t>John Doe</w:t> </w:r> </w:p> </w:body> </w:document>
And this is my php code:
<?php $xml = simplexml_load_file("doc1/word/document.xml"); $result = $xml->xpath("/w:document/w:body/w:p[1]/w:r[1]/w:t[1]");
Basically, John Doe should be George Doe
anon
source share