Hi I looped through an XML Document and searching for specific Word (that works) and after that i would like to a a certain Element if the word is included in that part.
<product>
<title>TestProduct</title>
<Specifications>
<item name="Specifications1">Test</item>
<item name="Specifications2">Hello World</item>
</Specifications>
<body>
<item name="Color">Black</item>
</body>
</product>
I tried this:
<?php
$dom = new DOMDocument;
$dom->load('Test.xml');
# set up the xpath
$xpath = new DOMXPath($dom);
$append= $dom->getElementsByTagName('Text');
print_r($append);
foreach ($xpath->query("*[contains(., 'Test')]") as $item) {
$element = $dom->createElement('ID', '123');
$append->appendChild($element);
}
?>
but it doesn't work can someone give me a hint? Tanks ;)