using system;
using system.drawing;
using system.collections;
using system.componentmodel;
using system.windows.forms;
using system.data;
using system.xml;
namespace windowsapplication3
{
/// <summary>
/// form1 的摘要说明。
/// </summary>
public class form1 : system.windows.forms.form
{
private system.windows.forms.button button1;
private xmldocument doc = new xmldocument();
private xmlnode attrcoll;
private system.windows.forms.button button2;
private system.windows.forms.helpprovider helpprovider1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private system.componentmodel.container components = null;
public form1()
{
//
// windows 窗体设计器支持所必需的
//
initializecomponent();
//
// todo: 在 initializecomponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.dispose();
}
}
base.dispose( disposing );
}
#region windows form designer generated code
/// <summary>
/// 设计器支持所需的方法 – 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void initializecomponent()
{
this.button1 = new system.windows.forms.button();
this.button2 = new system.windows.forms.button();
this.helpprovider1 = new system.windows.forms.helpprovider();
this.suspendlayout();
//
// button1
//
this.button1.location = new system.drawing.point(184, 32);
this.button1.name = "button1";
this.button1.tabindex = 0;
this.button1.text = "button1";
this.button1.click += new system.eventhandler(this.button1_click);
//
// button2
//
this.helpprovider1.sethelpnavigator(this.button2, system.windows.forms.helpnavigator.topic);
this.helpprovider1.sethelpstring(this.button2, "pppppp");
this.button2.location = new system.drawing.point(176, 88);
this.button2.name = "button2";
this.helpprovider1.setshowhelp(this.button2, true);
this.button2.tabindex = 1;
this.button2.text = "button2";
this.button2.mousehover += new system.eventhandler(this.button2_mousehover);
this.button2.helprequested += new system.windows.forms.helpeventhandler(this.button2_helprequested);
//
// form1
//
this.autoscalebasesize = new system.drawing.size(6, 14);
this.clientsize = new system.drawing.size(448, 285);
this.controls.addrange(new system.windows.forms.control[] {
this.button2,
this.button1});
this.helpbutton = true;
this.helpprovider1.sethelpnavigator(this, system.windows.forms.helpnavigator.tableofcontents);
this.helpprovider1.sethelpstring(this, "mmmmm");
this.maximizebox = false;
this.minimizebox = false;
this.name = "form1";
this.helpprovider1.setshowhelp(this, false);
this.text = "form1";
this.resumelayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[stathread]
static void main()
{
application.run(new form1());
}
private void button1_click(object sender, system.eventargs e)
{
// xmldocument doc = new xmldocument();
doc.load("http://localhost/data.xml");
//create an attribute collection.
// xmlnode attrcoll = doc.documentelement.selectsinglenode("//book");
attrcoll = doc.documentelement.selectsinglenode("//book/*");
this.selectednodes(attrcoll);
console.writeline("display all the attributes in the collection…\r\n");
}
private xmlnode selectednodes( xmlnode attrcoll)
{
xmlnode childnode;
xmlnode brothernode;
bool pd;
try
{
if( attrcoll.haschildnodes ==true)
{
childnode = selectednodes(attrcoll.firstchild);
return (childnode);
}
else
{
messagebox.show(attrcoll.name);
if( attrcoll.nextsibling != null)
{
attrcoll = attrcoll.nextsibling;
}
else
{
while(attrcoll.nextsibling == null)
{
messagebox.show(attrcoll.parentnode.name.tostring());
attrcoll = attrcoll.parentnode;
}
attrcoll = attrcoll.nextsibling;
// messagebox.show("ppp");
}
return ( selectednodes( attrcoll));
}
}
catch
{
}
return attrcoll;
}
private void button2_mousehover(object sender, system.eventargs e)
{
// this.button2.he
}
private void button2_helprequested(object sender, system.windows.forms.helpeventargs hlpevent)
{
// messagebox.show("www");
}
}//end the class
}//end the namespace
