Sublime Forum

XML Indent not working with CDATA containing < symbol

#1

I’ve been trying to use the XML Indent function, which as far as I remember is built into Sublime Text 2 ?

However, it seems it’s not possible to indent if the XML file contains HTML contained with a CDATA tag for an element, for example, my test example XML is:

<indent_me>
<![CDATA[s<text]]>
</indent_me>

In the console, I get:

Traceback (most recent call last):
  File ".\sublime_plugin.py", line 362, in run_
    return self.run(edit)
  File ".\indentxml.py", line 44, in run
  File ".\indentxml.py", line 96, in indent
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 24

However, if I remove the < from the CDATA content:

<indent_me>
<![CDATA[stext]]>
</indent_me>

Then it works fine and produces:

<indent_me>
    <![CDATA[stext]]>
</indent_me>
0 Likes