研究DesignerHosting,遇到关于xml文件的问题
这几天在研究上面这个东东,把自己设计好的窗体导出成xml文件后,如果获取xml文件的这些信息呢
下面的代码是xml文件的内容。我新增了三个控件:label,button和textbox,里面有对这三个控件的若干属性设置,比如:Name,Location属性等
我想问的问题是如何获取到呢?
我使用datatable.readxml不可以,用datatable.readxmlscheam也不可以。。。dataset的也不行。
<Object type="System.Windows.Forms.Form, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="Form1" children="Controls">
<Object type="System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="TextBox1" children="Controls">
<Property name="Size">100, 21</Property>
<Property name="DataBindings">
<Property name="DefaultDataSourceUpdateMode">OnValidation</Property>
</Property>
<Property name="Name">TextBox1</Property>
<Property name="Location">12, 68</Property>
<Property name="TabIndex">2</Property>
</Object>
<Object type="System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="Button1" children="Controls">
<Property name="TabIndex">1</Property>
<Property name="Name">Button1</Property>
<Property name="Size">75, 23</Property>
<Property name="UseVisualStyleBackColor">True</Property>
<Property name="Text">Button1</Property>
<Property name="Location">13, 39</Property>
<Property name="DataBindings">
<Property name="DefaultDataSourceUpdateMode">OnValidation</Property>
</Property>
</Object>
<Object type="System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="Label1" children="Controls">
<Property name="TabIndex">0</Property>
<Property name="Size">100, 23</Property>
<Property name="Text">Label1</Property>
<Property name="Location">13, 13</Property>
<Property name="DataBindings">
<Property name="DefaultDataSourceUpdateMode">OnValidation</Property>
</Property>
<Property name="Name">Label1</Property>
</Object>
<Property name="Name">Form1</Property>
<Property name="DataBindings">
<Property name="DefaultDataSourceUpdateMode">OnValidation</Property>
</Property>
<Property name="ClientSize">292, 273</Property>
</Object>
你可以使用XPathNigator方法去读取。