Sublime Forum

Snippet XML ERROR

#1

Hello, I need create a Snippet for CMS Joomla! and this is a XML, but I get a error:

[code]
<![CDATA[

<?xml version="1.0" encoding="utf-8"?> ]]> jsitecomponentmenu [/code]

Error parsing snippet xml: Error reading end tag.

How fix it?

Thanks!

0 Likes

#2

The error is here

]]>
0 Likes

#3

You can’t nest CDATA tags

0 Likes

#4

Understand, ok :smile:

Thanks!

0 Likes

#5

The problem is the XML parser sees the [size=85]]]>[/size] in your snippet code and then closes the [size=85]<![CDATA[[/b][/size] section. So your snippet file is actually being read like this:

[size=85][/size]<![CDATA[[/b]

<?xml version="1.0" encoding="utf-8"?> ** ]]>

I had a similar problem, but I fixed it by inserting a Sublime Text variable into the [size=85]]]>[/size] string in my code. Sublime Text snippet variables begin with a dollar sign character, for example: [size=85]$SELECTION[/size]. I discovered that if you use a snippet variable that isn’t defined, Sublime Text will replace it with an empty string. For example, if you changed your snippet content to the following code, it should solve your problem.

[size=85][/size]<![CDATA[[/b]

<?xml version="1.0" encoding="utf-8"?> ** **]]>**

Since the above solution is kind of a hack, you could alternatively use the real variable, [size=85]$SELECTION[/size], as long as your snippet doesn’t actually require any text to be selected. The end result is the same: by using [size=85]]][/size]$SELECTION> in your snippet code, the XML parser won’t have a problem with it, and Sublime Text will replace [size=85]$SELECTION[/size] with whatever text was selected when you triggered the snippet–which should be nothing–thus, the final output would just be [size=85]]]>[/size].

0 Likes