I have a rather unique situation where I need to make mass edits to an XML (or plain text) file. Within the XML file, there are several image references such as this one:
<image>
<id>image1</id>
<dateTaken>Sun Sep 9 10:57:31 GMT-0700 2012</dateTaken>
<dateAdded>Mon Jun 24 17:44:50 GMT-0700 2013</dateAdded>
<filename>0881DAF2-80EC-7A25-9CF3-BFD67F4EF764.jpg</filename>
</image>
What I need to do is take the file name between <filename>
and </filename>
, and use that to replace the portion between <id>
and </id>
. For example in the case above, I would need to replace "image1" with 0881DAF2-80EC-7A25-9CF3-BFD67F4EF764.jpg so it would look like this:
<image>
<id>0881DAF2-80EC-7A25-9CF3-BFD67F4EF764.jpg</id>
<dateTaken>Sun Sep 9 10:57:31 GMT-0700 2012</dateTaken>
<dateAdded>Mon Jun 24 17:44:50 GMT-0700 2013</dateAdded>
<filename>0881DAF2-80EC-7A25-9CF3-BFD67F4EF764.jpg</filename>
</image>
There are several hundred of these image references I need to change in this same document. Using PHP or another method, is there a quick way I can mass edit the document and replace the every ID between <id>
and </id>
with the content between <filename>
and </filename>
, in every <image>
</image>
reference within the document? Thanks a bunch for any possible help!