• Advertisement
Sign in to follow this  

XmlTextReader

This topic is 3876 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm trying to dynamically allocate form controls at runtime. The first step is to parse Form Designer files generated by visual studio. I didnt encounter any problems while writing the xml file (using xmltextwriter) but reading seems to be tricky.

XmlTextReader reader = new XmlTextReader("titles.xml");
reader.WhitespaceHandling = WhitespaceHandling.Significant;
reader.ReadStartElement("FormToXML");
string nsName = reader.ReadElementString("namespace");
string className = reader.ReadElementString("class");
reader.ReadStartElement("method");
reader.ReadElementString("name");
reader.ReadStartElement("statements");
reader.ReadStartElement("statement"); // exception here
"titles.xml"
<FormToXML>
  <namespace>Temas.Pack.Forms</namespace>
  <class>PackWorkerForm</class>
  <method>
    <name>InitializeComponent</name>
    <statements>
      <statement>
        <expression type>invocation</expression type>
        <caller>this</caller>
        <function>ResumeLayout</function>
        <arguments>
          <argument>
            <expression type>boolean</expression type>
            <value>False</value>
          </argument>
        </arguments>
      </statement>
    </statements>
  </method>
</FormToXML>

This is a simplified version of my xml file with only one statement but the problem is still there. (Exception: "< is unexpected token. The exptected token is '='") I think i have a problem with my xml format but i can't find the problem.

Share this post


Link to post
Share on other sites
Advertisement
I don't know if this is the only problem, but you can't have element names with spaces in them ("<expression type>"). Try something like expression_type.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement