Parsing XML with REGEX in Java

XML is not a regular language. You cannot parse it using a regular expression. An expression you think will work will break when you get nested tags, then when you fix that it will break on XML comments, then CDATA sections, then processor directives, then namespaces, … It cannot work, use an XML parser.

Leave a Comment