c# code 39 generator C HA P TER 2 M ANI P ULAT IN G X ML D OC UMEN TS BY US IN G TH E D O CUM ENT OB JE CT MO D EL in C#.NET

Encoder Code 39 in C#.NET C HA P TER 2 M ANI P ULAT IN G X ML D OC UMEN TS BY US IN G TH E D O CUM ENT OB JE CT MO D EL

C HA P TER 2 M ANI P ULAT IN G X ML D OC UMEN TS BY US IN G TH E D O CUM ENT OB JE CT MO D EL
Code 39 Encoder In C#
Using Barcode generation for .NET Control to generate, create Code 3/9 image in .NET framework applications.
www.OnBarcode.com
Reading Code39 In C#
Using Barcode scanner for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
Figure 2-13. Retrieving namespace details The application loads our new version of Employees.xml and extracts the NamespaceURI, Prefix, and LocalName properties of the document element. The namespace details are shown in labels. Listing 2-22 shows the Click event handler of the Load Document button. Listing 2-22. Retrieving Namespace Details private void button1_Click(object sender, EventArgs e) { XmlDocument doc = new XmlDocument(); doc.Load(Application.StartupPath + @"\employees.xml"); label4.Text = doc.DocumentElement.NamespaceURI; label5.Text = doc.DocumentElement.Prefix; label6.Text = doc.DocumentElement.LocalName; } The code loads the Employees.xml file by using the Load() method. It then simply retrieves the value of the NamespaceURI, Prefix, and LocalName properties. One thing to note is that these three properties are read-only properties. If you want to write these details, you must supply them while creating attributes, elements, and nodes from the XmlDocument class. Methods of the XmlDocument class such as CreateElement() and CreateAttribute() have appropriate overloads that allow you to specify namespace details.
EAN / UCC - 13 Encoder In C#.NET
Using Barcode drawer for VS .NET Control to generate, create GS1 128 image in .NET framework applications.
www.OnBarcode.com
ECC200 Creator In C#.NET
Using Barcode creator for .NET framework Control to generate, create Data Matrix 2d barcode image in .NET framework applications.
www.OnBarcode.com
Understanding Events of the XmlDocument Class
Encode Barcode In Visual C#.NET
Using Barcode printer for VS .NET Control to generate, create Barcode image in .NET applications.
www.OnBarcode.com
Code 128 Code Set B Printer In C#
Using Barcode creation for .NET framework Control to generate, create Code 128 Code Set A image in .NET framework applications.
www.OnBarcode.com
Whenever you modify an XML document, the XmlDocument class raises several events. These events follow a pre and post pattern. Pre-events are raised prior to the actual operation, whereas post-events are raised after the operation is over. These events are summarized in Table 2-3. Each of the events specified in the preceding table receives an event argument parameter of type XmlNodeChangedEventArgs. The XmlNodeChangedEventArgs class provides several properties. Some of them are listed in Table 2-4. To see some of these events in action, we will modify the same employee data-entry application that we developed previously. Modify the Form_Load event handler as shown in Listing 2-23.
Barcode Printer In C#
Using Barcode creator for .NET Control to generate, create Barcode image in VS .NET applications.
www.OnBarcode.com
Generate ISSN In Visual C#
Using Barcode encoder for VS .NET Control to generate, create International Standard Serial Number image in .NET applications.
www.OnBarcode.com
CH APT ER 2 MA NI PULA TI NG XM L DO CU MENT S B Y USI NG T H E D OC UMEN T O BJEC T MOD EL
Encode Code 39 Extended In Java
Using Barcode creation for Eclipse BIRT Control to generate, create Code 39 Full ASCII image in BIRT applications.
www.OnBarcode.com
Code 39 Encoder In None
Using Barcode encoder for Office Word Control to generate, create Code 39 image in Office Word applications.
www.OnBarcode.com
Table 2-3. Events of the XmlDocument Class
Scan Barcode In Java
Using Barcode Control SDK for Java Control to generate, create, read, scan barcode image in Java applications.
www.OnBarcode.com
Linear Barcode Encoder In Visual Basic .NET
Using Barcode drawer for .NET framework Control to generate, create Linear 1D Barcode image in .NET framework applications.
www.OnBarcode.com
Event Name
Generate Barcode In None
Using Barcode encoder for Microsoft Excel Control to generate, create Barcode image in Microsoft Excel applications.
www.OnBarcode.com
Barcode Creator In Java
Using Barcode encoder for Android Control to generate, create Barcode image in Android applications.
www.OnBarcode.com
NodeChanging NodeChanged NodeRemoving NodeRemoved NodeInserting NodeInserted
Code39 Drawer In VB.NET
Using Barcode creator for .NET Control to generate, create ANSI/AIM Code 39 image in VS .NET applications.
www.OnBarcode.com
Create EAN128 In None
Using Barcode drawer for Microsoft Word Control to generate, create GS1 128 image in Office Word applications.
www.OnBarcode.com
Description
Universal Product Code Version A Printer In Visual Studio .NET
Using Barcode generation for ASP.NET Control to generate, create UPC Symbol image in ASP.NET applications.
www.OnBarcode.com
Scanning Universal Product Code Version A In .NET
Using Barcode decoder for VS .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
This event is raised when the value of a node belonging to this document is about to be changed. This event is raised when the value of a node belonging to this document has been changed. This event is raised when a node belonging to this document is about to be removed from the document. This event is raised when a node belonging to this document has been removed from its parent. This event is raised when a node belonging to this document is about to be inserted into another node. This event is raised when a node belonging to this document has been inserted into another node.
Draw GS1 - 12 In VS .NET
Using Barcode generation for Reporting Service Control to generate, create UPC A image in Reporting Service applications.
www.OnBarcode.com
Code 39 Printer In VS .NET
Using Barcode generation for Reporting Service Control to generate, create ANSI/AIM Code 39 image in Reporting Service applications.
www.OnBarcode.com
Table 2-4. Properties of the XmlNodeChangedEventArgs Class
Property
Action
Description
Supplies information about the action that is causing the node to change. This property is an enumeration of type XmlNodeChangedAction. Possible values include Change, Remove, and Insert. Returns the parent XmlNode of the node being changed prior to the operation. Returns the parent XmlNode of the node being changed after the operation. Returns the value of the node prior to the operation. Returns the value of the node after the operation is complete. Returns an XmlNode object representing the node being affected.
OldParent NewParent OldValue NewValue Node
Listing 2-23. Attaching Event Handlers private void Form1_Load(object sender, EventArgs e) { doc.Load(Application.StartupPath + "/employees.xml"); doc.NodeChanged += new XmlNodeChangedEventHandler(doc_NodeChanged); doc.NodeInserted += new XmlNodeChangedEventHandler(doc_NodeInserted); doc.NodeRemoved += new XmlNodeChangedEventHandler(doc_NodeRemoved); foreach (XmlNode node in doc.DocumentElement.ChildNodes) { comboBox1.Items.Add(node.Attributes["employeeid"].Value); } FillControls(); }
C HA P TER 2 M ANI P ULAT IN G X ML D OC UMEN TS BY US IN G TH E D O CUM ENT OB JE CT MO D EL
Note the lines marked in bold. The code attaches event handlers to NodeChanged, NodeRemoved, and NodeInserted events, respectively. These events are of delegate type XmlNodeChangedEventHandler. The code in Listing 2-24 shows these event handlers. Listing 2-24. Handling Events of the XmlDocument Class void doc_NodeRemoved(object sender, XmlNodeChangedEventArgs e) { MessageBox.Show("Node " + e.Node.Name + " removed successfully!"); } void doc_NodeInserted(object sender, XmlNodeChangedEventArgs e) { MessageBox.Show("Node " + e.Node.Name + " added successfully!"); } void doc_NodeChanged(object sender, XmlNodeChangedEventArgs e) { MessageBox.Show("Node " + e.Node.Name + " changed successfully!"); } The code in each event handler simply displays the node being affected in a message box. To test these events, you need to run the application and try updating, deleting, and adding new employees. You will find that with every such operation, the NodeChanging, NodeRemoving, and NodeInserting events are raised. Figure 2-14 shows a sample run of the application.
Copyright © OnBarcode.com . All rights reserved.