=================== Using system; use system.drawing; use system.collections; use system.componentmodel; using system.windows.form; using system.data; using Summary for system.xml; using system.x; using system.xml.xpath; namespace xmlcreation {///
Public Form1 () {// // Windows Form Designer Support for // InitializeComponent ();
// // Todo: Add any constructor code after INITIALIZEComponent call //}
///
#REGION Windows Form Designer The code ///
/// summary> private void InitializeComponent () {this.textBox1 = new System.Windows.Forms.TextBox (); this.button1 = new System.Windows.Forms.Button (); this.button2 = new System. Windows.Forms.Button (); this.treeview1 = new system.windows.forms.treeview (); this.suspendlayout (); ////////////////////////////////////////////////////////////////////////////////////////////////////////> AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right))); this.textBox1.Location = new System.Drawing. Point (128, 8); this.textBox1.Multiline = true; this.textBox1.Name = "textBox1"; this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both; this.textBox1.Size = new System. Drawing.size (304, 312); this.textBox1.tabindex = 0; this.textBox1.text = ""; /// Button1 // this.button1.anchor = ((System.Windows.Forms.Anchorstyles) (System.Windows.Forms.Anchorstyles.bottom | System.windows.Forms.Anchorstyles.left)); This.Button1.Location = new system.drawing.point (48, 328); this.button1.name = "button1"; this.button1.tabindex = 1; this.button1.text = "create"; this.button1. Click = New System.EventHandler (this.button1_click); // // Button2 // this.button2.ancy = ((System.Windows.Forms.Anchorstyles ") ((System.Windows.Forms.Anchorstyles.Bottom | System. Windows.Forms.Anchorstyles.right))); this.Button2.Location = new system.drawing.point (320, 328); this.button2.name = "button2"; this.button2.tabindex = 2; this.button2 .Text = "path"; this.button2.click =
new System.EventHandler (this.button2_Click); // // treeView1 // this.treeView1.Anchor = ((System.Windows.Forms.AnchorStyles) ((((System.Windows.Forms.AnchorStyles.Top | System.Windows .Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.treeView1.ImageIndex = -1; this.treeView1.Location = new System. Drawing.point (8, 8); this.treeview1.name = "treec"; this.treeView1.selectedImageIndex = -1; this.treeView1.size = new system.drawing.size (120, 312); this.treeView1. TabINDEX = 3; // // Form1 // this.autoscalebasesize = new system.drawing.size (6, 14); this.clientsize = new system.drawing.size (440, 357); this.controls.add (this .treeView1); this.controls.add (this.button2); this.controls.add (this.button1); this.controls.add (this.TextBox1); this.name = "form1"; this.text = " Form1 "; this.load = new system.eventhandler (this.form1_load); this.ResumeLayout (false);} #ENDREGI on
///
while (iterator.MoveNext ()) {XmlTreeNode node = new XmlTreeNode (iterator.Current); node.FillTreeView (); XPathNodeIterator custIter = iterator.Current.SelectChildren ( "CustomerID", ""); while (custIter.MoveNext () ) Node.Text = Custiter.current.Value; TreeView1.nodes.Add (Node);}}
Private void form1_load (Object sender, system.eventargs e) {// this.loadXML (@ ".. /.); // this.loaddocxml2 (@" ../../ ORDERS.XML "); This.EDITXMLDOC_DEL (@" ../../ Books.xml "); this.loadTree ();} private void editXmldoc_del (string path) {xmldocument DC = new xmldocument (); dc.load (PATH) XMLNodeList ID = dc.getlementsBytagname ("book"); XMLNode Delnd = Null; Foreach (XMLNode ND Id) {IF (Nd.attributes ["ISBN"]. Value == "3-123904-23-4") {This.TextBox1.AppendText (nd.name ":" nd.innerxml); Delnd = nd;}} f (Delnd! = Null) {Delnd.ParentNode.RemoveChild (Delnd); Dc.Save (PATH); }} private void EditXmlDoc_Add (string path) {XmlDocument doc = new XmlDocument (); doc.Load (path); XmlElement newBook = doc.CreateElement ( "book"); newBook.SetAttribute ( "gener", "network"); Newbook.setttribute ("publicationDate", "2002"); newbook.setttribute ("ISBN", "3-123904-23-4"); xmlelement newTITE = Doc.createElement ("Title"); Newti tle.InnerText = "C # Network Programming"; newBook.AppendChild (newTitle); XmlElement newAuthor = doc.CreateElement ( "author"); XmlElement newAuthorFirstName = doc.CreateElement ( "first-name"); newAuthorFirstName.InnerText = "Bill "; XmlElement newAuthorLastName = doc.CreateElement (" last-name "); newAuthorLastName.InnerText =" Gate "; newAuthor.AppendChild (newAuthorFirstName); newAuthor.AppendChild (newAuthorLastName); newBook.AppendChild (newAuthor); XmlElement newPrice = doc. CreateElement ("
"); newprice.innertext =" 100.00 "; newbook.appendchild (newPrice); doc.documentelement .appendchild (newbook); doc.save (pat);
} Private void LoadDocXml2 (string path) {System.Xml.XmlDocument xmldoc = new XmlDocument (); xmldoc.Load (path); XmlNodeList nodes = xmldoc.SelectNodes ( "/ Entity / Sqls / Sql"); foreach (XmlNode nd in Nodes) {THIS.TEXTBOX1.APpendText ("/ R / NSQL statement: / r / n"); xmlattributeCollection atrs = nd.attributes; if (atrs! = null) {Foreach (XMLNode Attrs) {this.TextBox1. AppendText (attr.name ":" attr.innerText "");}} this.textBox1.AppendText ("/ R / n parameter list / r / n"); XMLNodelist Sons = nd.childNodes; Foreach (XMLNode SN In Sons) {Foreach (XMLNode AC in sn.attributes) {this.textBox1.AppendText (ac .Name ":" ac .innertext ");} this.textBox1.appendtext (" / r / n "); }}} private void LoadDocXml (string path) {System.Xml.XmlDocument xmldoc = new XmlDocument (); xmldoc.Load (path); XmlNodeList nodes = xmldoc.SelectNodes ( "/ Entity / Columns / Column"); foreach (XmlNode Node in nodes) {this.textBox1.AppendText (node.name "=== / r / n"); system.xml.xmlattributeCollection IE = node.attributes; if (ie == null) Continue; Foreach (XMLNode Attr in IE) {this.textBox1.AppendText (attr.name ": attr.innerText " ");} this.textbox1.appendtext (" / r / n ");}} private void loading {system.xml.xmlTextReader xr = new xmlTextReader (PATH); while (Xr.Read ()) {if (xr.nodetype == xmlnodetype.element) {textbox1.appendtext ("/ r / way ====" xr.name ":");
IF (Xr.haSattributes) {for (int i = 0; i private void button2_Click (object sender, System.EventArgs e) {XPathDocument doc = new XPathDocument (@ "../../ books.xml"); System.Xml.XPath.XPathNavigator nav = doc.CreateNavigator (); System. Xml.XPath.XPathNodeIterator itor = nav.SelectDescendants (XPathNodeType.Element, true); while (itor.MoveNext ()) {this.textBox1.AppendText (itor.Current.Name ":"); System.Xml.XPath. XPathNodeIterator chd = itor.Current.SelectChildren (XPathNodeType.Text); while (chd.MoveNext ()) {this.textBox1.AppendText ( ":" chd.Current.Value);} this.textBox1.AppendText ( "/ r / N ");}}}} / orders}}} / orders}}} / orders}}} / ots.xml XML version =" 1.0 "encoding =" uTF-8 "?> Employeeid "Direction =" INPUT "> param> param> Param name = "@ Empid" type = "system.int32" size = "4" SourceColoum = "EMPLOYEEID" Direction = "Input"> param> sourceColoum = "ShipRegion" Direction = "Input"> param> param> param> sql> sqls> entity> books.xml XML Version = "1.0" encoding = "UTF-8"?>