how to add data to xml node value while parsing xml in php

Hi,

I need to add cdata to a node in an xml while parsing xml. I was unable to parse the content from that node. i had added CDATA by editing the xml, it worked fine and able to parse. But i need to add CDATA on the fly while parsing the xml and need to read that value as string.

Please find the xml node that needs to be added with cdata in the attached xml.

<Descriptionlongue>
<p><strong>Froid Ventilé Multi Air Flow</strong><br/><strong>Classe Energétique A+</strong><br/><strong>Affichage LED</strong><br/><br/></p> <table class="fridge-mini-spec" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td>Volume total net <span>(L)</span></td> <td>432</td> </tr><tr><td>Volume utile du réfrigérateur <span>(L)</span></td> <td>290 </td> </tr><tr><td>Volume utile du congélateur <span>(L)</span></td> <td>142</td> </tr><tr><td>Classe énergétique</td> <td>A+</td> </tr><tr><td>Largeur * Profondeur * Hauteur (cm)</td> <td>79*70*181</td> </tr><tr><td>Finition</td> <td>Métal brillant</td> </tr></tbody></table>
</Descriptionlongue>
RQ562N4AC1-fr-1-.xml
srikanth saladiAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobOwner (Aidellio)Commented:
Unfortunately it's one of those chicken and egg problems... you can't add the node until you've parsed the code and you can't parse the code if it's not well formed.

What I suggest is reading in the xml file as a string, make the changes and then parse?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
srikanth saladiAuthor Commented:
Hi ,

Yes, it seems not possible to add CDATA while parsing. will go with suggested solution  of converting string and then applying changes and parsing
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.