The above code is demonstrating about DOMDocument usage with sample example. The example will fetch all H2 tags from the content and will form as separate list view.
DOMDocument is PHP library, which will be used to read, write and manipulate XML and HTML Documents. DOM (Document Object Model) is kind of API to validate the content of XML/ HTML. DOM support different namespaces as well.
To Discard White Spaces in content