Format output of $SimpleXML->asXML(); [duplicate]

There’s a variety of solutions in the comments on the PHP manual page for SimpleXMLElement. Not very efficient, but certainly terse, is a solution by Anonymous $dom = dom_import_simplexml($simpleXml)->ownerDocument; $dom->formatOutput = true; echo $dom->saveXML(); The PHP manual page comments are often good sources for common needs, as long as you filter out the patently wrong … Read more

Best JavaScript Date Parser & Formatter? [closed]

2014 update: Moment.js is an excellent date manipulation library, which includes parsing functions. It doesn’t include automatic date format detection, but you can specify multiple parsing patterns. Do you know the format of the dates before hand though, or are they user input? A deprecated library for parsing dates is Datejs. It hasn’t been updated … Read more

How can I remove punctuation from input text in Java?

This first removes all non-letter characters, folds to lowercase, then splits the input, doing all the work in a single line: String[] words = instring.replaceAll(“[^a-zA-Z ]”, “”).toLowerCase().split(“\\s+”); Spaces are initially left in the input so the split will still work. By removing the rubbish characters before splitting, you avoid having to loop through the elements.