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

Yes it is a little odd, I am using the 1 option as opposed to the 2 option as I don't like all the carriage returns :-) I've toyed and toyed with this for a whole day last week and it's just odd, that the document I created in the first place was with the same exact methods, steps etc as the 'revised' document. All this effort so I can make a new entry in this xml file and the lead on the project likes it a certain way.

I do thank you all for your input, even if I can't solve this the way I want, I have learned new things!
  • Comment on Re^4: xml::libxml open, add and save not formatting properly

Replies are listed 'Best First'.
Re^5: xml::libxml open, add and save not formatting properly
by ikegami (Patriarch) on Mar 24, 2010 at 00:36 UTC
    xmllint is a tool that uses libxml and comes with it. It's --format option does what you want. All the work appears to be done by a library function htmlSaveFileFormat. You could patch XML::LibXML to expose that function. You're not the first whose wanted a pretty print function from XML::LibXML.

    Update: The simplest solution would be to add an optional format argument to $doc->toStringHTML and swap in htmlDocDumpMemoryFormat for htmlDocDumpMemory in that function.

    Update: Never mind, htmlDocDumpMemory simply calls htmlDocDumpMemoryFormat with the format option set, and it doesn't help.