in reply to Re: xml::libxml open, add and save not formatting properly
in thread xml::libxml open, add and save not formatting properly

Ok, well-formed it is! I'm all self taught in all of this world so thanks for the correct term to be using in this situation.

As for the CDATA, this tool is for crawling and analysis of our clients web sites. I'm sure we all have experienced that a large portion of sites are at best, poorly built on a technical side, and ampersands and other markup characters are often in links, titles and other elements that we collect. I suppose I could check each entry to see if it contains a markup character and CDATA only the ones I need to.

Thanks for the input, I find that often I get confused with documentation, I was never one for being able to understand it, I am a much more hands on kind of learner, albeit, that costs it's own time and frustration, but if my mind doesn't grok it, I have to code and try it until I eventually do get it!
  • Comment on Re^2: xml::libxml open, add and save not formatting properly

Replies are listed 'Best First'.
Re^3: xml::libxml open, add and save not formatting properly
by ikegami (Patriarch) on Mar 24, 2010 at 18:08 UTC
    Instead of
    sub text_to_xml { my $s = shift; $s =~ s/]]>/]]>]]&gt;<![CDATA[/g; return "<![CDATA[$xml]]>"; }
    you could use
    use HTML::Entities qw( encode_entities ); sub text_to_xml { return encode_entities($text, '<&'); }