<ISSUES> <ISSUE> <ISSUE-DESC> <P nd="description"></P> <P nd="category"></P> <P nd="name"></P> <P nd="level"></P> <P nd="occurance"></P> </ISSUE-DESC> </ISSUE> </ISSUES>
#!/usr/bin/perl -w use strict; use XML::SMART; my $strTestString =' J&K; combine'; my $XML = XML::Smart->new(q`<?xml version="1.0" encoding="UTF-8" ?><IS +SUES><ISSUE><ISSUE-DESC><P></P></ISSUE-DESC></ISSUE></ISSUES>`, 'XML: +:Smart::Parser'); my $xmlfile = "C:/perl/xml/test.xml"; my $para={SI => 'description'}; $XML->{ISSUES}{ISSUE}{'ISSUE-DESC'}{P}[0]=$para; $XML->{ISSUES}{ISSUE}{'ISSUE-DESC'}{P}[0]->set_binary(0); $XML->{ISSUES}{ISSUE}{'ISSUE-DESC'}{P}[0]->set_cdata(1); $XML->{ISSUES}{ISSUE}{'ISSUE-DESC'}{P}[0]->content(0,"$strTestString") +; $XML->{ISSUES}{ISSUE}{'ISSUE-DESC'}{P}[1]->set_cdata(0); $XML->{ISSUES}{ISSUE}{'ISSUE-DESC'}{P}[1] = "test"; XML->save($xmlfile, nometagen => 1, forceutf8 => 1);
node always contains text and not CDATA.
Also there are some binary data in my text. this parser parse it as binary and puts it in an encoded way. But i dont want this behaviour instead i wanted them in CDATA. So i also set set_binary(0) but this is also ignored
I want CDATA only for my <P nd="description"></P> node and not any other <P>NODES. Is this possible?
I use XML::Smart v 1.6.9 and PERL 5.6.1 (this is the perl which is bundled with IBM Rational Clearcase)
Also to mention my XML encoding is UTF-8
Any help would be really appreciated
Best Regards
Karthik
In reply to CDATA probelm in XML::SMart by KarthikK
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |