3

I'm trying to put a for loop in my google gadget definition, but iGoogle Gadget Checker throws an error on a simple for loop.

Does anyone have any experience with this? Should I be using a different gadget validator?

<?xml version="1.0" encoding="UTF-8" ?>
<Module>
  <ModulePrefs title="Test Gadget">
  </ModulePrefs>
  <Content type="html">
    <script>
        for (var i=0; i<10; i++) {
          console.log(i);
        }
    </script>
  </Content>
</Module>
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Mike Smith
  • 39
  • 2
  • I figured this out...HTML needs to be surrounded by <![CDATA[ ... ]]>. My Javascript for loop had a '<' sign in the relational comparison that looked like an unclosed XML tag to the parser. – Mike Smith Nov 16 '11 at 16:36

1 Answers1

1

XML requires HTML character data to be defined with CDATA tags in order to not confuse the parser.

<?xml version="1.0" encoding="UTF-8" ?>
<Module>
    <ModulePrefs title="Test Gadget"></ModulePrefs>
    <Content type="html"><![CDATA[
        <script>
            for (var i=0; i<10; i++) {
                console.log(i);
            }
        </script>
    ]]></Content>
</Module>
Scottux
  • 1,577
  • 1
  • 11
  • 22