Skip to content
Advertisement

xPath problem while changing a XML file with PHP

I’m trying to modify a XML file. I tried same code with an more basic XML file and it worked perfectly. But when I use the same code for some other XML file with changing the path, I am getting this:

JavaScript

This is the XML file: (I sign the line I want to change for example)

JavaScript

So I use the code piece below:

JavaScript

I thought maybe the problem is about me, writing the path wrong but I check it couple of times and couldn’t see anything wrong. I’m totally stuck. Thanks for any idea/comment..

Advertisement

Answer

You need to account for namespaces in order to access the right element. Something like:

JavaScript

and you should see your expected output.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement