Different Node Value Types Retrieved via Casting to the Node Value's Type : XElement « XML LINQ « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# / C Sharp » XML LINQ » XElement 




Different Node Value Types Retrieved via Casting to the Node Value's Type
   

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Linq;
public class MainClass {
    public static void Main() {
        XElement count = new XElement("Count"12);
        Console.WriteLine(count);
        Console.WriteLine((int)count);

        XElement smoker = new XElement("Smoker"false);
        Console.WriteLine(smoker);
        Console.WriteLine((bool)smoker);

        XElement pi = new XElement("Pi"3.1415926535);
        Console.WriteLine(pi);
        Console.WriteLine((double)pi);
    }
}

   
    
  














Related examples in the same category
1.Create an XElement class with the specified name.
2.Create an XElement class with the specified name and content.
3.Create an XElement class from an XStreamingElement object.
4.The Elements method returns just the child nodes of type XElement
5.Calling the ToString Method on an Element Produces the XML Tree
6.Immediate Execution of the XML Tree Construction
7.Casting an Element to Its Value's Data Type Outputs the Value
8.Casting a Node to a Different Data Type Than Its Value's Original Data Type
9.Creating an Element Using the First Prototype
10.Use XElement.Parse to parse an element document
11.Is an element empty
12.Accessing the XML Document from an XElement Object via the Document Property
13.An Example with a Single Book
14.Adding a Node to the End of the Specified Node's Child Nodes with Add
15.Obtaining Elements Without Reaching
16.Obtaining Restricted Elements Without Reaching
17.Obtaining Restricted Elements Without Reaching While Ordering and Using Query Expression Syntax
18.Suppressing Node Construction with null
19.Generates an Empty Element
20.Prevents an Empty Element
21.Handling Multiple Peer Nodes While Maintaining a Flat Structure
22.XElement.Load("Employee.xml")
23.Create XML document from object list
24.Creates the XML Tree
25.Saving an Element with the XElement.Save Method
26.Loading an Element with the XElement.Load Method
27.Parsing an XML String into an Element
28.XElement Class Represents an XML element.
29.Use Linq to create XElement
30.Create a new XElement class from another XElement object.
31.XElement.HasElements gets a value indicating whether this element has at least one child element.
32.XElement.IsEmpty gets a value indicating whether this element contains no content.
33.Count the node with whitespace
34.Get line number and line position
35.XElement.Name gets or sets the name of this element.
36.XElement.NodeType gets the node type for this node.
37.XElement.SetElementValue sets the value of a child element, adds a child element, or removes a child element.
38.XElement.SetValue sets the value of this element.
39.XElement.Value gets or sets the concatenated text contents of this element.
40.XElement.WriteTo writes this element to an XmlWriter.
41.XElement to Boolean Cast
42.XElement to DateTime Cast
43.Rename element
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.