tags:

views:

34

answers:

1

I have an XML file which im fetching using php . That file contains '&' which gives error while fetching the file. Now i want to replace this "&" from my XML.How can i do that using php???

+1  A: 

The simplest way is with string replace:

str_replace("&", "&", $xml_str);

http://php.net/manual/en/function.str-replace.php

Have in mind that if you have "&" in the xml they will become "&" So you can try:

str_replace("&", "&", $xml_str);
str_replace("&", "&", $xml_str);
Ilian Iliev
this thing will work when i'll be able to read xml file.Since my xml file is giving error on retrieval i need a code that can replace the text in the file in one go without retrieving it.
developer
Do not parse the XML. Just read it as text and replace it. If you can not read it from specific file/url than this is other problem.
Ilian Iliev
problem is solved now.We were taking data from another server and file was giving an error while even opening it on URL.So we asked them to make the file properly and now its running fine.Thanks!!
developer