.TableOfContents is an HTML string, not an array or tree structure. Parse it as a tree structure so that we can write better versions of it with some default HTML rendering for backwards compatibility and those happy with the way it is.
Reference this discussion.