Name cannot begin with the ' ' character

后端 未结 9 1246
抹茶落季
抹茶落季 2021-01-01 08:57

I\'m parsing some XML in C#. I\'m getting it from a database, and so converting it to a MemoryStream before reading it with an XmlTextReader. The problem is that I get this

相关标签:
9条回答
  • 2021-01-01 09:34

    Another common source of this error is when the XmlReader attempts to read your scripts as xml. That's a good reason to start commenting out scripts after the script tags. They will still run:

    <script language="javascript" type="text/javascript">
    <!--
        function myFunction() {
        }
        ...
    -->
    </script>
    
    0 讨论(0)
  • 2021-01-01 09:35

    Yes, you should delete the space between <? and xml.

    <?xml version="1.0" encoding="utf-8" ?>
    <form>
       <e order="0" type="custom" name="test">
          <fi type="text" />
          <o />
       </e>
       <e order="1" type="zip" />
       <e order="2" type="state" />
    </form>
    

    Here's the relevant XML spec.

    0 讨论(0)
  • 2021-01-01 09:35

    My error in same case was that file wasn't saved as UTF-8.

    0 讨论(0)
提交回复
热议问题