I have an XML string which consists of two xml files. (For the sake of readability I cut the below xml string):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" ...
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" ...
I want to loop through each xml document and replace the text within <a:t>
tags with a variable. The code below does that and works correctly, however only for the first xml document. It doesn't continue when it comes to the second <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
xml declaration.
How can I loop through multiple xml declarations and execute the code below?
$reader = new XMLReader();
$reader->xml($extract);
while (@$reader->read()) {
if (@$reader->nodeType == XMLREADER::ELEMENT && $reader->name === 'a:t'){
$i++;
$string = @$reader->readString();
$extract = str_replace($string, $i, $extract);
}
}