So I have an XML file (XML export of a MS Word file). What I am just trying to do is to replace these two lines:
<w:t>Meno:</w:t>
And:
<w:t>Priezvisko:</w:t>
This is a longer XML excerpt:
<w:p w:rsidR="00CF175F" w:rsidRDefault="00CF175F">
−
<w:r>
<w:t>Meno:</w:t>
</w:r>
</w:p>
−
<w:p w:rsidR="00CF175F" w:rsidRDefault="00CF175F">
−
<w:r>
<w:t>Priezvisko:</w:t>
</w:r>
</w:p>
I am doing it like this:
$xml = file_get_contents('file.xml');
$doc = new DOMDocument();
$doc->loadXML($xml);
$doc->preserveWhiteSpace = false;
$wts = $doc->getElementsByTagNameNS('http://schemas.openxmlformats.org/wordprocessingml/2006/main','t');
foreach ($wts as $wt) {
echo 1;
//if ('Meno:' === substr($wt->nodevalue, 0, 5)) {
//echo 1;
//}
}
That script echoes nothing. Why does the getElementsByTagName not work? There are tens of w:t tags in the XML.