PHP - Preserving character data when updating XML using DOM

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

gravs
New php-forum User
New php-forum User
Posts: 1
Joined: Mon Oct 22, 2012 4:56 pm

PHP - Preserving character data when updating XML using DOM

Postby gravs » Mon Oct 22, 2012 5:02 pm

Hi,

I am reading an XML document into a DOM tree, then updating a node, and finally writing the tree into another XML file. The source XML file has below tag(I am not touching this tag in DOM) like
<TRANSFORMFIELD DATATYPE ="string" DEFAULTVALUE ="ERROR(&apos;transformation error&apos;)" DESCRIPTION ="" EXPRESSION ="DECODE (TRUE, &#xD;&#xA;IncomingOrgType=&apos;Capsils&apos;)" EXPRESSIONTYPE ="GENERAL" NAME ="OutgoingCarrierCode" PICTURETEXT ="" PORTTYPE ="OUTPUT" PRECISION ="10" SCALE ="0"/>

when using DOM->Save or SaveXML function, it is converting it to below
<TRANSFORMFIELD DATATYPE="string" DEFAULTVALUE="ERROR('transformation error')" DESCRIPTION="" EXPRESSION="DECODE (TRUE, &#13;&#10;IncomingOrgType='Capsils')" EXPRESSIONTYPE="GENERAL" NAME="OutgoingCarrierCode" PICTURETEXT="" PORTTYPE="OUTPUT" PRECISION="10" SCALE="0"/>

I want to preserve the original format as I am not touching this node in the update process. I've tried a few things and have been searching for a solution. It would be great if you can help figure out how to preserve the format of source XML when dumping DOM tree to a file.

Thanks in advance!

Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 2 guests

cron