THuG has asked for the wisdom of the Perl Monks concerning the following question:
I was using XML::Simple to make very minor edits to some proprietary XML. It works well enough, but when I use XML::Simple's XMLout to save the XML hash, it strips the CDATA tags, leaving the enclosed text in the XML output.
Before I start down another XML library that may not do what I need it to do, I thought I'd ask for suggestions. Or perhaps someone knows how to get XML::Simple to preserve the CDATA tags.
I need a simple XML parser that I can use to do a quick read in of a small XML document, make a couple of changes, and then output the XML again without stripping the CDATA tags.
p.s. In response to ikegami, I am using XML::Simple's XMLout to turn the hash from XMLin back into XML. I haven't seen a flag for getting it to re-encase the bare text. Mind you, the source only seemed to use CDATA some of the time, not all of the time.
<TABLE> <ROW> <SITNAME> BS_NT_DEF_OPS_SVC_Auto_Crit </SITNAME> <TEXT> <![CDATA[Critical threshold for SVC (Automatic Service not Running)]]> </TEXT> <AFFINITIES> 00080000000000000000000000000000#*########F </AFFINITIES> <PDT> <![CDATA[*IF *VALUE NT_Services.Start_Type *EQ Automatic *AND *VALUE NT_Services.Current_State *NE Running]]> </PDT> <REEV_DAYS> 0 </REEV_DAYS> <REEV_TIME> 000300 </REEV_TIME> <AUTOSTART> *YES </AUTOSTART> <ADVISE> <![CDATA[*NONE]]> </ADVISE> <CMD> <![CDATA[net start "&NT_Services.Service_Name"]]> </CMD> <AUTOSOPT> YNN </AUTOSOPT> <DISTRIBUTION> BL_NT_DEF,BL_NT_DEF_V </DISTRIBUTION> <ALERTLIST> </ALERTLIST> <HUB> </HUB> <QIBSCOPE> E </QIBSCOPE> <SENDMSGQ> *NONE </SENDMSGQ> <DESTNODE> </DESTNODE> <LOCFLAG> </LOCFLAG> <LSTCCSID> en_US </LSTCCSID> <LSTDATE> 1080528162416000 </LSTDATE> <LSTRELEASE> V100 </LSTRELEASE> <LSTUSRPRF> u758725 </LSTUSRPRF> <NOTIFYARGS> </NOTIFYARGS> <NOTIFYOPTS> </NOTIFYOPTS> <OBJECTLOCK> </OBJECTLOCK> <PRNAMES> </PRNAMES> <REFLEXOK> </REFLEXOK> <SITINFO> <![CDATA[COUNT=2;ATOM=NTSERVICE.SRVCNAME;TFWD=Y;SEV=Fatal;TDST=0;~]]> </SITINFO> <SOURCE> </SOURCE> </ROW> </TABLE>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Preserving CDATA Tags When Saving XML
by mirod (Canon) on Jul 31, 2008 at 21:12 UTC | |
|
Re: Preserving CDATA Tags When Saving XML
by ikegami (Patriarch) on Jul 31, 2008 at 21:02 UTC | |
|
Re: Preserving CDATA Tags When Saving XML
by pajout (Curate) on Aug 01, 2008 at 15:12 UTC |