Hey there I have a little problem. I tried to preg_match a whole xml file for specified words but it doesn't work
my xml:
<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>
And i would like to cut and remove certain words out of the whole file using preg_match.
my php:
for ($i = 0; $i <= $length; $i++) {
$var = $xml->product[$i];
if (preg_match_all('/\b(\w*Test\w*)\b|\b(\w*Black\w*)\b/', $var, $result)){
do something
}
But it doesn't work only when i replace
$var->$xml->product[$i];
with
$var->$xml->product[$i]-> Specifications->item;
it matchs Test
How can i fix that i am out of ideas Thanks for help!