XML namespace missing for parser
<p>I have to parse a XML where the xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" namespace is missing, so the xml looks like this: </p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes" ?&gt;
&lt;program&gt;
  &lt;scriptList&gt;
  &lt;script type="StartScript"&gt;
    &lt;isUserScript&gt;false&lt;/isUserScript&gt;
  &lt;/script&gt;
  &lt;/scriptList&gt;
&lt;/program&gt;
</code></pre>

<p>but should look like this: </p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes" ?&gt;
&lt;program xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" &gt;
  &lt;scriptList&gt;
    &lt;script xsi:type="StartScript"&gt;
      &lt;isUserScript&gt;false&lt;/isUserScript&gt;
    &lt;/script&gt;
  &lt;/scriptList&gt;
&lt;/program&gt;
</code></pre>

<p>The type attribute ensures the correct subclass e.g. </p>

<pre><code>class StartScript : script
{...}
</code></pre>

<p>The parser is auto generated from an handwritten xsd via $> xsd.exe a.xsd /classes (.Net).
Here is the xsd:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
elementFormDefault="qualified" attributeFormDefault="qualified"&gt;

  &lt;!-- Main element --&gt;
  &lt;xs:element name="program"&gt;
    &lt;xs:complexType&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element name="scriptList"&gt;
          &lt;xs:complexType&gt;
            &lt;xs:sequence&gt;
              &lt;xs:element name="script" type="script" maxOccurs="unbounded"/&gt;
            &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
      &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;

  &lt;xs:complexType name="script" /&gt;

  &lt;xs:complexType name="StartScript"&gt;
    &lt;xs:complexContent&gt;
      &lt;xs:extension base="script"&gt;
        &lt;xs:all&gt;
          &lt;xs:element name="isUserScript" type="xs:boolean"&gt;&lt;/xs:element&gt;
        &lt;/xs:all&gt;
      &lt;/xs:extension&gt;
    &lt;/xs:complexContent&gt;
  &lt;/xs:complexType&gt;
</code></pre>

<p>A simple solution is to run a string-replace (" type=\"" to " xsi:type=\"") on the input XML but this is pretty ugly.
Is there a better solution?</p>