You are here:  » How to search in only one node


How to search in only one node

Submitted by abyman on Tue, 2011-10-25 10:02 in

HI, i'm triying to search a simbol "," and replace for "." but only inside that one node.

if I use
$xml_entities_search = array(",");

$xml_entities_replace = array(".");

can be search in all docment

changes in all the xml and i don't like this

<DEAL>
<NOMBRE>xxxx</NOMBRE>
<ID>
1111111
</ID>
<TITLE>
i'm the tittle
</TITLE>
<IMG>
urlformimage.jpg
</IMG>
<PRICE>
i'mtheprice
</PRICE>
<DISCOUNT>
Here it's the unique node when i would like to search and replace, how i can search only here?
</DISCOUNT>
<VALUE>
i'm value
</VALUE>

Submitted by support on Tue, 2011-10-25 11:50

Hi abyman,

Rather than search and replace within the entire document I would perform the operation at the top of your myRecordHandler function prior to the rest of your normal handling code; for example:

$record["DISCOUNT"] = str_replace(",",".",$record["DISCOUNT"]);

Hope this helps!
Cheers,
David.